Knockout is a standalone JavaScript implementation of the Model–View–ViewModel pattern with templates.
KnockoutJS MCQs: This section contains multiple-choice questions and answers on the various topics of KnockoutJS. Practice these MCQs to test and enhance your skills on KnockoutJS.
List of KnockoutJS MCQs
1. KnockoutJS library is written in which language?
- Python
- Java
- JavaScript
- C
- C++
Answer: C) JavaScript
Explanation:
KnockoutJS library is written in JavaScript.
2. KnockoutJS was developed by ____?
- Håkon Wium
- Tim Berners-Lee
- Brendan Eich
- Steve Sanderson
Answer: D) Steve Sanderson
Explanation:
KnockoutJS library was developed by Steve Sanderson.
3. KnockoutJS is based upon which pattern?
- MVVM
- MVC
- MVCM
Answer: A) MVVM
Explanation:
KnockoutJS library is based upon Model -View-ViewModel.
4. Does KnockoutJS supports responsive development?
- Yes
- No
Answer: A) Yes
Explanation:
KnockoutJS library creates a website that is responsive.
5. Does KnockoutJS depends on any other framework?
- Yes
- No
Answer: B) No
Explanation:
KnockoutJS library is independent of any other framework.
ADVERTISEMENT
6. Is KnockoutJS open source?
- Yes
- No
Answer: A) Yes
Explanation:
KnockoutJS library is an open-source library.
7. In the MVVM pattern the data which is stored in the application comes under which component?
- Model
- View
- ViewModel
Answer: A) Model
Explanation:
In the MVVM pattern the data which is stored in the application comes under the Model component.
8. In the MVVM pattern, the user interface part of the application comes under which component?
- Model
- View
- ViewModel
Answer: B) View
Explanation:
In the MVVM pattern, the user interfaces part of the application comes under the View component.
9. Which of the following abbreviation is used for KnockoutJS?
- KJS
- KO.JS
- KO
Answer: C) OK
Explanation:
KO is the abbreviation that we used for KnockoutJS.
10. Does KO support all the mainstream browsers?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, KO supports all the mainstream browsers: Firefox 3.5+, Chrome, Opera, and Safari (desktop/mobile).
ADVERTISEMENT
11. Does KO support the automatic UI refresh feature?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, KO supports an automatic UI refresh feature.
12. In the code given below, string refers to which type of variable
this.String = ko.observable(“Enter String”);?
- Model
- View
- ViewModel
Answer: C) ViewModel
Explanation:
String refers to the ViewModel variable.
13. ____ is a notion that monitors value changes in order to update the underlying ViewModel data.
- KO.this
- KO.observable
- KO.write
- KO.observe
Answer: B) KO.observable
Explanation:
KO.observable is a notion that monitors value changes in order to update the underlying ViewModel data.
14. KnockoutJS is widely used for ____
- Full stack-based application
- Multiple-page application
- Single-page application
- None
Answer: C) Single-page application
Explanation:
KnockoutJS is widely used for Single Page Applications.
15. KnockoutJS is a ____
- Client-server side framework
- Client-side framework
- Server-side framework
Answer: B) Client-side framework
Explanation:
KnockoutJS is a client-side framework.
ADVERTISEMENT
16. In KnockoutJS, Because of the ____ attribute, all data remains synchronized.
- Observable
- This
- Data bind
Answer: A) Observable
Explanation:
In KnockoutJS because of the Observable attribute, all data remains synchronized.
17. ____ is just a user interface built using HTML components and CSS style.
- ViewModel
- Model
- View
Answer: C) View
Explanation:
View is just a user interface built using HTML components and CSS style.
18. ____ is a JavaScript object that provides the attributes and methods required to represent data.
- ViewModel
- Model
- View
Answer: A) ViewModel
Explanation:
ViewModel is a JavaScript object that provides the attributes and methods required to represent data.
19. ____ is the domain data on the server, and it is modified when the ViewModel request is sent/received.
- ViewModel
- Model
- View
Answer: B) Model
Explanation:
The model is the domain data on the server, and it is modified when the ViewModel request is sent/received.
20. Who developed MVVM pattern?
- Tim Berners-Lee
- Trygve Reenskaug
- John Gossman
Answer: C) John Gossman
Explanation:
John Gossman developed the MVVM pattern.
ADVERTISEMENT
21. In which year MVVM pattern came into existence?
- 2001
- 2005
- 2008
- 2009
Answer: B) 2005
Explanation:
MVVM pattern came into existence in the year 2005.
22. Which pattern is better MVC or MVVM?
- MVC
- MVVM
Answer: B) MVVM
Explanation:
MVVM pattern is quite better than the MVM pattern, due to its one-way data and dependency flow.
23. ____ connects DOM components to ViewModel.
- Observable
- This
- Data bind
Answer: C) Data bind
Explanation:
‘Data-bind’ connects DOM components to ViewModel.
24. Which of the following is the correct syntax to use observable attributes in KO?
- Observable = ko.this (‘value’);
- this.property = ko.observable(‘value’);
- this.observable = ko.this(‘value’);
Answer: B) this.property = ko.observable(‘value’);
Explanation:
this.property = ko.observable(‘value’); is the correct syntax to use observable attribute in KO.
25. Which of the following is the correct syntax to create an empty array?
- this.arrayName = ko.observableArray();
- arrayName = this.observableArray();
- KO.arrayName = this.observableArray();
Answer: A) this.arrayName = ko.observableArray();
Explanation:
this.arrayName = ko.observableArray(); is the correct syntax to create an empty array.
26. Which of the following method is used to add a new item to the end of the array?
- Add()
- Insert()
- Push()
- Add_end()
Answer: C) Push()
Explanation:
The push() method is used to add a new item to the end of the array.
27. Which of the following method is used to add a new value to the array’s beginning?
- Shift()
- Insert()
- Add()
- Unshift()
Answer: D) Unshift()
Explanation:
Unshift() method is used to add a new value to the array’s beginning.
28. Which of the following method is used to eliminate the last item from the arrays and returns it?
- Del()
- Pop()
- Delete()
- Remove()
Answer: B) Pop()
Explanation:
The pop() method is used to eliminate the last item from the arrays and returns it.
29. Which of the following method is used to remove and returns the first item from the array?
- Shift()
- Unshift()
- ShiftF()
- First()
Answer: A) Shift()
Explanation:
The shift() method is used to remove and returns the first item from the array.
30. Which of the following method returns the index of the first occurrence of the specified argument?
- Index()
- First()
- Element()
- IndexOf()
Answer: D) IndexOf()
Explanation:
IndexOf method returns the index of the first occurrence of the specified argument.
ADVERTISEMENT
31. Which of the following method removes all items and returns an array of them?
- Pop()
- Remove()
- Delete
- RemoveAll()
Answer: B) Remove()
Explanation:
Remove method removes all items and returns an array of them.
32. Is the Remove() method and Pop() method the same?
- Yes
- No
Answer: B) NO
Explanation:
No, they are not the same. The remove() method removes all items and returns an array of them, whereas the Pop() method is used to eliminate the last item from the arrays and return it.
33. A ____is a function that is reliant on one or more observables and that automatically updates when those underlying observables (dependencies) change?
- Computed observable
- Observable
- Marked Observable
Answer: A) Computed observable
Explanation:
A computed observable is a function that is reliant on one or more observables and that automatically updates when those underlying observables (dependencies) change.
34. If the property is Computed Observable, which of the following method returns true?
- Ko.isobservable
- ko.isComputed
- ko.Computedis
Answer: B) ko.isComputed
Explanation:
ko.isComputed returns true, If the property is Computed Observable.
35. Which of the following method, returns true if the property is Observable?
- ko.isObservable
- ko.isComputed
- ko.Computedis
Answer: A) ko.isObservable
Explanation:
ko.isObservable method, returns true if the property is Observable.
36. Computed Observable is ____
- Read and write only
- Write only
- Read only
Answer: C) Read only
Explanation:
Computed Observable is Read-only.
37. Is observable and bindings the same thing?
- Yes
- No
Answer: B) NO
Explanation:
No, they are not the same.
38. Binding in KO consists of how many items?
- 3
- 4
- 2
- 5
Answer: C) 2
Explanation:
The binding consists of 2 items, the binding name, and value.
39. The binding value can be a ____
- Single value
- Literal,
- A variable
- JavaScript expression.
- All of the above
Answer: E) All of the above
Explanation:
The binding value can be a single value, a literal, a variable, or can be a JavaScript expression.
40. An object might relate to the data utilized in the current bindings. This object is referred to as the ____
- Declarative binding
- View binding
- Binding context
Answer: C) Binding context
Explanation:
An object might relate to the data utilized in the current bindings. This object is referred to as the binding context.
41. Which of the following binding context type, is always the top-level ViewModel?
- $root
- $data
- $index
- $parent
Answer: A) $root
Explanation:
$root binding context type, is always the top-level ViewModel.
42. In the current condition, which of the following binding context type, contains raw ViewModel value?
- $data
- $index
- $parent
- $rawdata
- $raw
Answer: D) $rawdata
Explanation:
In the current condition, $rawdata context contains raw ViewModel value.
43. When the values are modified, KnockoutJs automatically records the dependencies. It just has one object named ____
- Tracker
- Dependent tracker
- Dependency tracker
- None
- All of the above
Answer: C) Dependency tracker
Explanation:
When the values are modified, KnockoutJs automatically records the dependencies. It just has one object named dependency tracker.
44. Using the ____ function, you may access the Computed Observable without incurring a dependence.
- Peak
- Tracker
- Peek
- This
Answer: C) Peek
Explanation:
Using the peek function, you may access the Computed Observable without incurring a dependence.
45. The ____method allows you to ignore dependencies in the calculated dependencies that you do not wish to track.
- ko.ignore
- ko.ignoreDependencies
- ko.Dependencies
- ko.ignoreDependeny
Answer: B) ko.ignoreDependencies
Explanation:
The ko.ignoreDependencies method allows you to ignore dependencies in the calculated dependencies that you do not wish to track.
46. A ____ is a collection of DOM components that may be used repeatedly.
- Template
- Component
- Module
- Unit
Answer: A) Template
Explanation:
A template is a collection of DOM components that may be used repeatedly.
47. In how many ways you can create templates in KnockoutJS?
- 4
- 5
- 3
- 2
Answer: D) 2
Explanation:
There are 2 ways of creating templates: Native templating, and String-based templating
48. Which of the following method of creating a template supports the control flow bindings such as foreach, with, and if?
- Native templating
- String-based templating
Answer: A) Native templating
Explanation:
Native templating of creating template supports the control flow bindings such as foreach, with, and if.
49. In which of the following method of creating a template no external library is required?
- Native templating
- String-based templating
Answer: A) Native templating
Explanation:
Native templating does not require any external library.
50. Components can register using the ____ API
- ko.components.register()
- ko.components.observable()
- ko.register()
Answer: A) ko.components.register()
Explanation:
Components can register using the ko.components.register() API.
51. Which of the following method, generates a new view Each component has its own model object?
- Observable function
- Constructor function
- Shared object instance
Answer: B) Constructor function
Explanation:
The constructor function generates a new view Each component has its own model object.
52. Custom element is a way to rendering a component?
- Element
- Constructor
- Component
- Custom element
Answer: D) Custom element
Explanation:
A custom element is a way for rendering a component.
53. Which of the following method is used to remove the component from the registry?
- ko.components.eliminate(name)
- ko.components.unregister(name)
- ko.components.remove(name)
Answer: B) ko.components.unregister(name)
Explanation:
ko.components.unregister(name), is used to remove the component from the registry.
54. Which of the following type of templating, links to a third-party engine to send information ViewModel parameters?
- Native templating
- String-based templating
- All of the above
Answer: B) String-based templating
Explanation:
String-based templating links to a third-party engine to send information ViewModel parameters.
55. How many types of data binding does KnockoutJS supports?
- 5
- 4
- 2
- 3
Answer: C) 2
Explanation:
Knockout JS supports two types of data binding:
- One-way binding
- Two-way binding
56. How many context properties are there in KnockoutJS?
- 5
- 4
- 2
- 3
Answer: C) 2
Explanation:
There are two context properties:
- $index, and
- $parent property
57. Which of the following are the alternatives of KnockoutJS?
- Angular.
- Chart.Js.
- angularjs.
- Backbone.js.
- All of the above
Answer: E) All of the above
Explanation:
Following are the alternatives of KnockoutJS:
- Angular.
- Chart.Js.
- angularjs.
- Backbone.js.
58. Which of the following companies used KnockoutJS?
- AMC Theatres
- Azure
- Dominos.jp
- Pillsbury.com
- All of the above
Answer: E) All of the above
Explanation:
Following are the companies that use KnockoutJS:
- AMC Theatres
- Azure
- Dominos.jp
- Pillsbury.com