ADVERTISEMENT
ADVERTISEMENT

AngularJS Multiple-Choice Questions (MCQs)

AngularJS is a JavaScript-based open-source front-end web framework for developing single-page applications. It is maintained mainly by Google and a community of individuals and corporations.

AngularJS MCQs: This section contains AngularJS Multiple-Choice Questions with Answers. These AngularJS MCQs are written for beginners as well as advanced, practice these MCQs to enhance and test the knowledge of AngularJS.

List of AngularJS MCQs

1. AngularJS is perfect for _______.

  1. Create Single Page Applications
  2. Creating a Desktop Application
  3. Create Web Services
  4. None of these

Answer: A) Create Single Page Applications

Explanation:

AngularJS is perfect for creating Single Page Applications (SPAs).


2. AngularJS is a _____.

  1. HTML Framework
  2. .Net Framework
  3. JavaScript framework
  4. Oracle Framework

Answer: C) JavaScript framework

Explanation:

AngularJS is a JavaScript framework.


3. AngularJS is distributed as a _______.

  1. JavaScript file
  2. PHP file
  3. XML file
  4. ASP file

Answer: A) JavaScript file

Explanation:

AngularJS is distributed as a JavaScript file.


4. Who developed AngularJS?

  1. Jesse James Garrett
  2. Douglas Crockford
  3. Miško Hevery
  4. Brendan Eich

Answer: C) Miško Hevery

Explanation:

AngularJS was developed by Miško Hevery.


5. Who maintained AngularJS?

  1. Google
  2. A community of individuals and corporations
  3. Oracle
  4. Both A. and B.

Answer: D) Both A. and B.

Explanation:

AngularJS is maintained by the Angular Team at Google and by a community of individuals and corporations.


6. Is AngularJS free for commercial use?

  1. Yes
  2. No

Answer: A) Yes

Explanation:

Yes, AngularJS is free for commercial use.


7. AngularJS expressions are written inside _____.

  1. { expression }
  2. [{ expression }]
  3. _expression
  4. {{ expression }}

Answer: D) {{ expression }}

Explanation:

AngularJS expressions are written inside double braces: {{ expression }}.


8. Which directive can be used to write AngularJS expressions?

  1. ng-expression
  2. ng-bind
  3. ng-statement
  4. ng-bindexpression

Answer: B) ng-bind

Explanation:

The ng-bind can be used to write AngularJS expressions.


9. Which is the correct syntax to write an AngularJS expression using the ng-bind directive?

  1. ng-bind="expression"
  2. ng-bind={expression}
  3. ng-bind={"expression"}
  4. ng-bind="{{expression}}"

Answer: A) ng-bind="expression"

Explanation:

The correct syntax to write an AngularJS expression using the ng-bind directive is: ng-bind="expression"


10. An AngularJS module defines an ______.

  1. expression
  2. application
  3. element
  4. None of the above

Answer: B) application

Explanation:

An AngularJS module defines an application.


11. Which AngularJS function is used to create a module?

  1. module
  2. ng-bind
  3. angular.create
  4. angular.module

Answer: D) angular.module

Explanation:

AngularJS function angular.module is used to create a module.


12. Which is the correct syntax to create a module?

  1. var variable_name = angular.module("app_name", []);
  2. var variable_name = angular.module("app_name", []);
  3. var variable_name = angular.module("app_name", []);
  4. var variable_name = angular.module("app_name", []);

Answer: A) var variable_name = angular.module("app_name", []);

Explanation:

The correct syntax to create a module using the angular.module is:

var variable_name = angular.module("app_name", []);

13. In the below given statement, "myApp" parameter refers to ____.

  1. a JavaScript code in which the application will run
  2. a JSON file
  3. an HTML element in which the application will run
  4. SQL queries

Answer: C) an HTML element in which the application will run

Explanation:

In the given statement, myApp parameter refers to an HTML element in which the application will run.


14. Which prefix is used with the AngularJS directives?

  1. ag-
  2. ng-
  3. aj-
  4. All of the above

Answer: B) ng-

Explanation:

The ng- prefix is used with the AngularJS directives.


15. Which directive initializes an AngularJS application?

  1. ng-app
  2. ng-init
  3. ng-model
  4. ng-application

Answer: A) ng-app

Explanation:

The ng-app directive initializes an AngularJS application.


16. Which directive initializes application data?

  1. ng-app
  2. ng-init
  3. ng-model
  4. ng-application

Answer: B) ng-init

Explanation:

The ng-init directive initializes application data.


17. Which directive binds the value of HTML controls to application data?

  1. ng-app
  2. ng-init
  3. ng-model
  4. ng-application

Answer: C) ng-model

Explanation:

The ng-model directive binds the value of HTML controls to application data.


18. Which directive repeats an HTML element?

  1. ng-repeats
  2. ng-iterate
  3. ng-model
  4. ng-repeat

Answer: D) ng-repeat

Explanation:

The ng-repeat directive repeats an HTML element.


19. Which directive defines initial values for an AngularJS application?

  1. ng-app
  2. ng-init
  3. ng-model
  4. ng-repeat

Answer: B) ng-init

Explanation:

The ng-init directive defines initial values for an AngularJS application.


20. Write a statement with <div> element to initialize two variables (name and age)?

  1. <div ng-app="" ng-init="Name:'Alex';Age:21">
  2. <div ng-app="" ng-init="Name:'Alex',Age:21">
  3. <div ng-app="" ng-init="Name='Alex',Age=21">
  4. <div ng-app="" ng-init="Name='Alex';Age=21">

Answer: D) <div ng-app="" ng-init="Name='Alex';Age=21">

Explanation:

The correct statement to initiate the variables:

<div ng-app="" ng-init="Name='Alex';Age=21">

21. Consider the below statement, how to print the value of "StudentName"?

<div ng-app="" ng-init="firstName='John'">
	<p>Input something in the input box:</p>
	<p>Name: <input type="text" ng-model="StudentName"></p>
	<p>You wrote: _______</p>
</div>
  1. StudentName
  2. {{ StudentName }}
  3. { StudentName }
  4. { _StudentName }

Answer: B) {{ StudentName }}

Explanation:

The code is:

<div ng-app="" ng-init="firstName='John'">
	<p>Input something in the input box:</p>
	<p>Name: <input type="text" ng-model="StudentName"></p>
	<p>You wrote: {{ StudentName }}</p>
</div>

22. Consider the below statement – what will be the output?

<div data-ng-app="" data-ng-init="qty=3;price=2.5">
	<p>The result is: {{qty * price}}</p>
</div>
  1. The result is: 7.5
  2. The result is: 7
  3. The result is: 7.50
  4. The result is: 3*2.5

Answer: A) The result is: 7.5

Explanation:

The output of the above statement is: The result is: 7.5


23. Consider the below statement – what will be the output?

<div data-ng-app="" data-ng-init="qty=3;">
	<p>The result is: {{qty * price}}</p>
</div>
  1. The result is: Undefined
  2. The result is: 0
  3. The result is: 3
  4. The result is: NaN

Answer: D) The result is: NaN

Explanation:

The output of the above statement is: The result is: NaN


24. Consider the below statement – what will be the output?

<div ng-app="" ng-init="cities=['Mumbai','New Delhi','Banglore']">
  <p>The cities...</p>
  <ul>
    <li ng-repeat="c in cities">
      {{ c }}
    </li>
  </ul>
</div>
  1. Prints the city names in an unordered list
  2. Prints the city names in an ordered list
  3. Prints the all name of the city 3 times in an unordered list
  4. None of the above

Answer: A) Prints the city names in an unordered list

Explanation:

The output will be:

The cities...

  • Mumbai
  • New Delhi
  • Banglore

25. Consider the below statement – what will be the output?

<div ng-app="" ng-init="cities=['Mumbai','New Delhi','Banglore']">
  <p>The cities...</p>
  <ul>
    <li ng-repeat="c in cities">
      "Hello" {{ c }}
    </li>
  </ul>
</div>
  1. Prints the city names with "Hello" in an unordered list
  2. Prints the city names with "Hello" in an ordered list
  3. Prints the all name of the city with "Hello" 3 times in an unordered list
  4. None of the above

Answer: A) Prints the city names with "Hello" in an unordered list

Explanation:

The output will be:

The cities...

  • "Hello" Mumbai
  • "Hello" New Delhi
  • "Hello" Banglore

26. Consider the below statement – what will be the output?

<div ng-app="" ng-init="values=[10, 20, 30]">
  <p>The value is {{values[0]}}, {{values[3]}}</p>
</div>
  1. The value is 10, 30
  2. The value is 10, 0
  3. The value is 10, NaN
  4. The value is 10,

Answer: D) The value is 10,

Explanation:

The output will be "The value is 10,". Because array indexing starts with 0 and ends with length of the array -1. In the above statement, there are only 3 elements and the last index is 2. Thus the statement {{values[3]}} will print nothing.


27. Consider the below statement – what will be the output?

<div ng-app="" ng-init="values=[10, 20, 30]">
  <p>The value is {{values[0]}} + {{values[2]}}</p>
</div>
  1. The value is 10 + 30
  2. The value is 40
  3. The value is NaN
  4. The value is Undefined

Answer: A) The value is 10 + 30

Explanation:

The output will be "The value is 10 + 30". Here, the addition operation will not be performed it will just print.


28. Which AngularJS function creates a new directive?

  1. .new
  2. .create
  3. .directive
  4. .CreateDirective

Answer: C) .directive

Explanation:

The AngularJS function .directive is used to create new directive.


29. Which directive defines the application controller?

  1. ng-control
  2. ng-controller
  3. ng-NewController
  4. None of the above

Answer: B) ng-controller

Explanation:

The ng-controller directive defines the application controller.


30. Filters can be added to expressions by using the ______, followed by a filter.

  1. comma character (,)
  2. Colon character (:)
  3. Hyphen character (-)
  4. pipe character (|)

Answer: D) pipe character (|)

Explanation:

Filters can be added to expressions by using the pipe character (|), followed by a filter.


31. Which AngularJS filter formats a number to a currency format?

  1. currency
  2. number
  3. dollar
  4. curr

Answer: A) currency

Explanation:

AngularJS currency is used to format a number to a currency format.


32. Which AngularJS filter formats a date to a specified format?

  1. datetime
  2. time
  3. date
  4. ng-date

Answer: C) date

Explanation:

AngularJS date is used to format a date to a specified format.


33. Which AngularJS filter selects a subset of items from an array?

  1. set
  2. subset
  3. ng-set
  4. filter

Answer: D) filter

Explanation:

AngularJS filter filter is used to select a subset of items from an array.


34. Which AngularJS filter formats an object to a JSON string?

  1. ng-json
  2. json
  3. set-json
  4. None of the above

Answer: B) json

Explanation:

AngularJS filter json is used to format an object to a JSON string.


35. Which AngularJS filter limits an array/string, into a specified number of elements/characters?

  1. limitTo
  2. limit
  3. ng-limit
  4. ng-limitTo

Answer: A) limitTo

Explanation:

AngularJS filter limitTo is used to limit an array/string, into a specified number of elements/characters.


36. Which AngularJS filter formats a string to lower case?

  1. lwr
  2. lower
  3. lowercase
  4. ng-lowercase

Answer: C) lowercase

Explanation:

AngularJS filter lowercase is used to format a string to lower case.


37. Which AngularJS filter formats a string to upper case?

  1. upr
  2. upper
  3. uppercase
  4. ng-uppercase

Answer: C) uppercase

Explanation:

AngularJS filter uppercase is used to format a string to upper case.


38. Which AngularJS filter formats a number to a string?

  1. number
  2. integer
  3. int
  4. num

Answer: A) number

Explanation:

AngularJS filter number is used to format a number to a string.


39. Which AngularJS filter orders an array by an expression?

  1. orderby
  2. orderBy
  3. order
  4. OrderBy

Answer: B) orderBy

Explanation:

AngularJS filter orderBy is used to order an array by an expression.


40. Which is the correct AngularJS statement to format the value of "studentName" in the uppercase?

  1. {{ studentName.uppercase }}
  2. {{ uppercase(studentName) }}
  3. {{ uppercase.studentName }}
  4. {{ studentName | uppercase }}

Answer: D) {{ studentName | uppercase }}

Explanation:

The correct AngularJS statement to format the value of studentName in the uppercase is: {{ studentName | uppercase }}


41. Which is the correct AngularJS statement to format the value of "studentName" in the uppercase?

  1. {{ studentName.uppercase }}
  2. {{ uppercase(studentName) }}
  3. {{ uppercase.studentName }}
  4. {{ studentName | uppercase }}

Answer: D) {{ studentName | uppercase }}

Explanation:

The correct AngularJS statement to format the value of studentName in the uppercase is: {{ studentName | uppercase }}


42. Which is the correct syntax to define multiple filters on an expression?

  1. {{ expression | filter1 | filter2 | filter3 | ... }}
  2. {{ expression | {filter1} | {filter2} | {filter3} | ... }}
  3. {{ expression | {{filter1}} | {{filter2}} | {{filter3}} | ... }}
  4. {{ expression | filter1 , filter2 , filter3 , ... }}

Answer: A) {{ expression | filter1 | filter2 | filter3 | ... }}

Explanation:

The correct syntax to define multiple filters on an expression is: {{ expression | filter1 | filter2 | filter3 | ... }}


43. Which AngularJS service has the set of methods to get the information about the location of the current web?

  1. $web
  2. $current
  3. $location
  4. All of the above

Answer: C) $location

Explanation:

The AngularJS service $location has methods to get the information about the location of the current web page.


44. Which method of $location service is used to get the full URL of the current web page?

  1. url()
  2. Url()
  3. WebUrl()
  4. absUrl()

Answer: D) absUrl()

Explanation:

The $location.absUrl() returns the full URL of the current web page.


45. Which method of $location service is used to get the URL without base prefix?

  1. url()
  2. Url()
  3. WebUrl()
  4. absUrl()

Answer: A) url()

Explanation:

The $location.url() returns the URL without base prefix.


46. Which method of $location service is used to get the URL without base prefix?

  1. localhost()
  2. host()
  3. absHost()
  4. absLocalHost()

Answer: B) host()

Explanation:

The $location.host() returns the host of the current web page URL.


47. Which method of $location service is used to get the current URL without any parameters?

  1. url()
  2. absUrl()
  3. path()
  4. absPath()

Answer: C) path()

Explanation:

The $location.path() returns the current URL without any parameters.


48. Which method of $location service is used to get the search part of the current URL when called without any parameter?

  1. searchPath()
  2. absSearch()
  3. ruleSearch()
  4. search()

Answer: D) search()

Explanation:

The $location.search() returns the search part of the current URL when called without any parameter.


49. Which is not a valid method of $location service?

  1. hostname()
  2. host()
  3. path()
  4. hash()

Answer: A) hostname()

Explanation:

There is no function named hostname() in $location service.


50. Which AngularJS service is used to make the request to the server?

  1. $https
  2. $request
  3. $http
  4. $requests

Answer: C) $http

Explanation:

The Angular service $http is used to make a request to the server.


51. Which AngularJS service is the version of the window.setTimeout function?

  1. $timeout
  2. $WindowTimeout
  3. $WinTimeout
  4. $setTimeout

Answer: A) $timeout

Explanation:

The AngularJS service $timeout is the version of the window.setTimeout function.


52. Which AngularJS service is the version of the window.setInterval function?

  1. $interval
  2. $WindowInterval
  3. $WinInterval
  4. $setInterval

Answer: A) $interval

Explanation:

The AngularJS service $interval is the version of the window.setInterval function.


53. AngularJS is entirely based on HTML and JavaScript?

  1. True
  2. False

Answer: A) True

Explanation:

It's true that – AngularJS is entirely based on HTML and JavaScript.


54. Can we create custom directives in AngularJS?

  1. Yes
  2. No

Answer: A) Yes

Explanation:

Yes, we can create custom directories in AngularJS.


55. In AngularJS, what is the data binding?

  1. Synchronization between controller part and view part
  2. Synchronization between model part and controller part
  3. Synchronization between model part and view part
  4. None of the above

Answer: C) Synchronization between model part and view part

Explanation:

Data binding is the synchronization between model part and view part in AngularJS.


56. Which AngularJS directive is used to bind AngularJS application data to the disabled attribute of HTML elements?

  1. ng-disabled
  2. ng-disable
  3. ng-disabledElement
  4. ng-disableElement

Answer: A) ng-disabled

Explanation:

The ng-disabled directive is used to bind AngularJS application data to the disabled attribute of HTML elements.


57. Which AngularJS directive is used to show or hide an HTML element?

  1. ng-showHide
  2. ng-ShowHide
  3. ng-show
  4. ng-hide

Answer: C) ng-show

Explanation:

The ng-show directive is used to show or hide an HTML element.


58. Which AngularJS directive is used to hide or show an HTML element?

  1. ng-showHide
  2. ng-ShowHide
  3. ng-show
  4. ng-hide

Answer: D) ng-hide

Explanation:

The ng-hide directive is used to hide or show an HTML element.


59. Which AngularJS directive is used to define AngularJS code that will be executed when the element is being clicked?

  1. ng-click
  2. ng-mouseOver
  3. ng-mouseClick
  4. ng-mouse

Answer: A) ng-click

Explanation:

The ng-click directive is used to define AngularJS code that will be executed when the element is being clicked.


60. Which is the correct syntax of AngularJS directive ng-show?

  1. ng-show:"true/false"
  2. ng-show="true/false"
  3. ng-app ng-show="true/false"
  4. None of the above

Answer: B) ng-show="true/false"

Explanation:

The syntax of AngularJS directive ng-show is: ng-show="true/false"


61. Consider the below statement – what will be the output?

<div ng-app="" ng-init="num=10">
	<p ng-show="num > 5">Displaying: {{num}}</p>
</div>
  1. Syntax Error
  2. Nothing will display
  3. Displaying: 5
  4. Displaying: 10

Answer: D) Displaying: 10

Explanation:

In the above code, the expression is evaluated with the ng-show which is valid with AngularJS. Thus, the output will be "Displaying: 10".


62. The $event object contains the ______.

  1. browser's event object
  2. browser's current path
  3. Both A. and B.
  4. None of the above

Answer: A) browser's event object

Explanation:

The $event object contains the browser's event object.


63. Which module routes your application to different pages without reloading the entire application?

  1. ngRoutes
  2. route
  3. ng-Route
  4. ngRoute

Answer: D) ngRoute

Explanation:

The ngRoute module routes your application to different pages without reloading the entire application.


64. Which of the below is an Invalid filter in AngularJS?

  1. JSON
  2. limitTo
  3. orderBy
  4. email

Answer: D) email

Explanation:

The email is an invalid filter in AngularJS.


65. The .subscribe in AngularJS is used for?

  1. Streams data synchronously
  2. Streams data asynchronously
  3. Both of the above
  4. None of the above

Answer: C) Both of the above

Explanation:

The .subscribe is used for the both:

  • Streams data synchronously
  • Streams data asynchronously


ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!



ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.