HTML Questions and Answers Part-19

1. In localStorage object data ________
a) is deleted after the browser has been closed
b) is not deleted after the browser has been closed
c) can be seen but can not edit
d) can be seen as well as edit

Answer: b
Explanation: Data with no expiration date is stored by localStorage object. Here the data is not deleted if we close the browser. We can have data at the next day or week or year.

2. In sessionStorage object data __________
a) is not deleted after the browser has been closed
b) can be seen but can’t edit
c) can be seen as well as edit
d) is deleted after the browser has been closed

Answer: d
Explanation: sessionStorage object works same as localStorage object except the data is stored for one session only. When the use closes the browser the data is deleted.

3. What is the limit of character storage for chrome 23.0 in localStorage?
a) unlimited
b) none
c) 1021 k
d) 4.98 M

Answer: b
Explanation: We can’t store any character in localStorage in chrome 23.0, for chrome 18.0 it is unlimited i.e. can store any number of characters, for chrome 19.77 it is 1021 k, for chrome 22.0 it is 2.49 M, for chrome 24.0, 25.0, 27.0 it is 2.49 M, for chrome 28.0, 30.0, 31.0 and 31.1 it is 4.98 M.

4. What is the limit of character storage for chrome 23.0 in sessionStorage?
a) 510 k
b) unlimited
c) 1021 k
d) 2.49 M

Answer: a
Explanation: We can store 510 k characters in sessionStorage in chrome 23.0, for chrome 18.0 and chrome 24.0 we can store unlimited characters, for chrome 19.77 its value is 1021 k, for chrome 25.0 and 27.0 it is 2.49 M, for chrome 28.0, 30.0, 31.0, 31.1 its value is 4.98 M.

5. Which of the following is not a web storage interface?
a) storage
b) window
c) storageEvent
d) privacy

Answer: d
Explanation: There is only three web storage interface window, storage, and StorageEvent. Window object provides access to the local storage objects. Storage retrieves, set and remove data from the domain. Storage event is fired when the storage area on a document’s window changes.

6. Which of the following returns a number of value pairs?
a) storage.key(n)
b) storage.length
c) storage.setItem(key,value)
d) storage.clear()

Answer: b
Explanation: storage.length returns number of value pairs that are currently present in the list, storage.key(n) returns name of nth key from the list, storagesetItem(key,value) sets the value which is identified by key to value, storage.clear() empties the list which is associated with values.

7. Which of the following is invoked when it is not fired on window object?
a) removeItem()
b) clear()
c) setItem()
d) getItem()

Answer: d
Explanation: When removeItem(), clear() and setItem() are invoked the events are fired on window object, which accesses newly stored or removed data, as defined by LocalStorage and sessionStorage attributes, getItem(key) method returns the current value associated with the key.

8. Which of the following is not the storageEvent interface?
a) event.newValue
b) event.url
c) event.key
d) event.clear

Answer: d
Explanation: There are many storgeEvent interfaces like event.key, event.newValue, event.url, event.oldValue, event.storageArea. Event.key returns the key if the storage item is changed, event.oldValue and event.newValue returns old value and the new value of the key whose value has been changed. Event.url returns the URL of a document which has been changed.

9. For clearing all the settings which function should be called?
a) localStorage.remove(key)
b) localStorage.clear()
c) localStorage.remove()
d) localStorage.clearAll()

Answer: b
Explanation: If we want to delete all the setting we can call localStorage.clear() method, localStorage.remove(key) only removes the key of the value that we have given. Same can be applied with sessionStorage also the syntax will be sessionStorage.clear().

10. Which of the following is not the form type for adding text?
a) Text input
b) Text area
c) Password input
d) Submit button

Answer: d
Explanation: There are many types of form controls. Adding text, Submitting forms, Making choices and Uploading files are some of them. For an adding text, we can use Text input, Text area, and Password input. For making choices there are checkboxes, radio buttons, and drop-down boxes.