0% found this document useful (0 votes)
30 views15 pages

Advanced JavaScript QA

Uploaded by

saeejagtap.06
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views15 pages

Advanced JavaScript QA

Uploaded by

saeejagtap.06
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Advanced JavaScript: Question Bank

Fill in the following blanks:


1. There are a variety of scripting languages used to develop _____ websites.
Ans. dynamic

2. A _____ is a set of instructions used to produce various kinds of outputs.


Ans. Program

3. JavaScript supports _____ programming facility.


Ans. event based

4. ____ script resides on web server.


Ans. Server side

5. _____ script resides on client computer and can run on the client page.
Ans. Client side

6. ______ is a JavaScript based framework for building interactive user interface.


Ans. Vue JS

7. _____ is a JavaScript based open source front-end web framework developed


for single page application.
Ans. Angular JS

8. ____ consists of JS libraries for building UI for single page application and
mobile apps.
Ans. React

9. In a switch case statement, the value for the case must be of a similar ____ as
the variable in switch.
Ans. data type

10. _____ property of window sets or returns the fact in the status bar of a window.
Ans. Status

11. for-loop has a combination of _____, _____ and _____ in single statement.
Ans. initialization, condition, iteration

12. A JavaScript object is an entity having ____ and ____.


Ans. state, behavior

13. _____ method of window object display the alert box containing message with
OK button.
Ans. alert ()
14. An object can group data together with _____ needed to manipulate it.
Ans. functions

15. JavaScript supports 2 types of objects; _____ and ____objects.


Ans. built-in, user defined

16. Math, String, Array, Date are examples of _____objects.


Ans. built in

17. When an HTML document is loaded into a ____, it becomes a document object.
Ans. web browser

18. _____ defines logical structure of document.


Ans. Document object

19. _____ method of window object calls a function or evaluates an expression


after a specified number of milliseconds.
Ans, setTimeout ()

20. The ______of DOM was founded by W3C(World Wide Web Consortium).
Ans. standardization

21. _____ DOM property is used to set the title of the document.
Ans. Title
22. DOM method ____ works same as write(), but adds a newline character after
each statement.
Ans. writeln()

23. _____ method of number object converts the given string into an integer
number.
Ans. parseFloat ()

24. _____ method returns cube root of a number.


Ans. cbrt()

25. DOM’s ____method is the easiest method for accessing form elements.
Ans. getElementById()

26. The ____ property is useful for getting html element and changing its content.
Ans. innerHTML

27. _____ object is the peak of the object Hierarchy.


Ans. Window

28. _____ Window Object property returns the location object for the window.
Ans. Location

29. Window Object method ____ is used to print the content of current window.
Ans. print()

30. JavaScript events are actions done by the user or an application that occurs
on_____.
Ans. the webpage

31. ____ Window Object property returns a boolean value to indicate whether a
window is closed or not.
Ans. Closed

32. ______ event occurs when user selects some text of an element.
Ans. onselect

33. ______ event handler occurs when page/image has been loaded.
Ans. onload

34. JavaScript built-in objects provide different ____and ____ that are useful while
creating live web pages.
Ans. properties, methods

35. ____ is used to store zero or more characters of text within single or double
quotes.
Ans. String

36. String object is used to ____ and___ text.


Ans. store, manipulate

37. String object property _____ is used to return the number of characters in a
string.
Ans. length

38. String object Method charAt() is used to return the character at a ____ .
Ans. specified position

39. ______ String object method is used to remove whitespace from both sides of a
string.
Ans. trim()

40. The built-in math object includes mathematical ____ and ____.
Ans. constants, functions

41. Math method____ returns the base to the exponent power.


Ans. pow(x, y)

42. Date method _____ is used to return the day of the week.
Ans. getDay()
43. Array property index is used to represent the ____ index of the match in the
string.
Ans. zero-based

44. Array property _____ reflects number of elements in array.


Ans. length

45. _____ array method is used to join two or more arrays.


Ans. concat()

46. ____ array method is used to copy array elements within the array.
Ans. copyWithin()

47. Array method find() is used to return the value of the ____ in an array that
satisfies a test in testing.
Ans. first element

48. The index of the first element of an array is ____.


Ans. zero

49. Date method getMonth() is used to return ____.


Ans. month

50. Which date method is used to set the hours of a date object?
Ans. setHours()

51. Date method setMinutes() is used to set the ___of a date object.
Ans. minutes

52. Date method ____ is used to set the seconds of a date object.
Ans. setSeconds()

53. Number object MIN_VALUE() property returns the largest ___value.


Ans. minimum

54. _____ Number property is used to return the largest maximum value.
Ans. MAX_VALUE

55. Number property ___ is used to represent ‘Not A Number’ value.


Ans. NaN

56. _____ number method is used to convert the given string into a integer number.
Ans. parseInt()

57. _____is an object that can store a collection of items.


Ans. Array

58. _____ array method is used to reverse the order of the elements in an array.
Ans. reverse()

59. _____ array method is used to sort the elements of an array.


Ans. sort()

State whether the following statements are true or false:


1. JavaScript is an interpreted scripting language.
Ans. True

2. JavaScript was initially created to “make webpages alive”.


Ans. True

3. JavaScript is a light weight scripting language because it supports all features


of object oriented programming languages.
Ans. False

4. Users don’t need any special software to run JavaScript programs


Ans. True

5. JavaScript is not a case sensitive language.


Ans. False

6. Most of the JavaScript “Control Statements” are same as control statements in


other programming languages.
Ans. True

7. JavaScript is a platform dependent scripting language


Ans. False

8. JavaScript is known as a universal client side scripting language.


Ans. True

9. JavaScript has the ability to create new functions within scripts.


Ans. False

10. To execute the Server side script, it must be activated by server, and then it is
executed on web server.
Ans. False

11. JavaScript has a built-in multi-way decision statement known as switch.


Ans. True

12. The default statement for switch case is mandatory.


Ans. False

13. In switch cases, there should not be duplicity between the cases.
Ans. True
14. Iteration refers to the execution of a statement or a group of statements of code
for a fixed number of times or till the condition is satisfied.
Ans. True

15. The condition of a looping statement should not be Boolean condition.


Ans. False

16. Location property of window object returns a Boolean value indicating


wheteher the window has been closed or not.
Ans. False

17. In for loop, the control comes out from the loop when condition becomes false.
Ans. True

18. Initialization executes only once in the for loop.


Ans. True

19. The statements in the for loop statement block will execute till the condition is
false.
Ans. False

20. While loop executes statements as long as the condition is true.


Ans. True

21. The statement within the while loop may only have single line statement.
Ans. False

22. If condition is always true then the loop would be executed infinitely, so after
some execution the condition becomes false.
Ans. True

23. Almost everything in JavaScript is an object.


Ans. True

24. Properties and methods of objects are accessed with ‘.’ operator.
Ans. True

25. JavaScript gives facility to create user defined objects as per user
requirements.
Ans. True

26. trim() adds white spaces from both sides of a string.


Ans. False

27. ceil() method returns the next integer greater than or equal to a given number.
Ans. True

28. A break statement is used to make an early exit from a loop.


Ans. True

29. World Wide Web Consortium works for standardization of web technologies.
Ans. True

30. DOM property “URL” returns full URL of the HTML document.
Ans. True

31. DOM property “img” returns Error! Filename not specified.


Ans. True

32. DOM method write() is used to write HTML expressions or JavaScript code to A
document.
Ans. True.

33. DOM method getElementById() uses id property to find an element.


Ans. True

34. pow() method returns the base to the exponent power.


Ans. True

35. The innerHTML property can be changed by any HTML element, includingand.
Ans. True

36. Window object is the parent object of all other objects.


Ans. True

37. Window Object property “document” is used to return the document object for
the window.
Ans. True

38. confirm() Method is used to open new window in Window Object


Ans. False

39. Window Object Method close() is used to close the current window.
Ans. True

40. Window Object method blur() is used to add focus to the current window.
Ans. False

41. JavaScript Event Handler “onblur” occurs when the user leaves the field or
losses focus of an element.
Ans. True

42. JavaScript Event Handler “onfocus” occurs when an element losses focus.
Ans. False

43. “onreset” Event Handler occurs when user clicks the cancel button.
Ans. False

44. JavaScript built-in objects operate independently.


Ans. True

45. Users always need to create the Math object before using it.
Ans. False

46. cbrt(x) Math method returns the cube root of a number.


Ans. True

47. Math method random(x) gives random number between 0 and 10.
Ans. False

48. Math method sqrt(x) gives the square root of a number.


Ans. True

49. The Date object is used to create date and time values.
Ans. True

50. Date Method getFullYear() is used to return the year in four digits.
Ans. True

51. Date Method getHours() is used to return the hour from 0-12.
Ans. False

52. Arrays are useful when we need to store large amounts of data of the same
type.
Ans. True

53. Arrays are used to store single values in single variables.


Ans. False

54. You set the items in an array by referring to its item number.
Ans. False

55. Array method forEach() is used to call a function for some array element.
Ans. False

56. Date getSeconds() Method is used to return the seconds from 0-24.
Ans. False

57. Date Method getTime() is used to return the number of milliseconds since
midnight Jan 1, 1970 00.00.00.
Ans. True

58. Date Method setFullYear() is used to set the full year if a date object.
Ans. True
59. Date Method setMonth() is used to set the year of a date object.
Ans. False

60. Number object helps us to work with numbers.


Ans. True

61. JavaScript does not provide properties and methods for primitive values.
Ans. False

62. Number method isInteger() determines whether the given value is an integer.
Ans. True

63. Array method push() adds new elements to the end of an array.
Ans. True

Multiple choice questions:


1. An interpreted language is a type of programming language that executes its
instructions ____.
1. Indirectly
2. Directly
3. Partially
4. None of above
Ans. 2

2. The programs in this language are called____.


1. Page
2. Webpage
3. Scripts
4. Block
Ans. 3

3. JavaScript helps the browser to perform_____ validation.


1. Output
2. Input
3. Both of above
4. None of above
Ans. 2

4. JavaScript provides the ability to create new functions within____.


1. Scripts
2. Function
3. Class
4. None of above
Ans. 1

5. We can declare a function in JavaScript using ____ keyword.


1. New
2. Function
3. Default
4. Do
Ans. 2

6. Client side scripts are placed inside ____document.


1. Word
2. HTML
3. XML
4. Text
Ans. 2

7. JavaScript has a built–in multiway decision statement known as___.


1. If else
2. Do while
3. Switch
4. for
Ans. 3

8. _____is assigning initial value to the variable.


1. Condition
2. Initialization
3. Iteration
4. None of above
Ans. 2

9. In the ‘for loop’, when condition becomes ___control is transferred out of the
loop.
1. True
2. False
3. End
4. Terminate
Ans. 2

10. If the statement within while loop is a single line then the ____ parenthesis is
optional.
1. Square
2. Curly
3. Round
4. None of above
Ans. 2

11. Loop will be executed repeatedly till the ____is true.


1. Condition
2. Initialization
3. Iteration
4. None of above
Ans. 1

12. ____statement is used to jump out of loop.


1. End
2. Out
3. Break
4. Remove
Ans. 3

13. What happens if the break statement is encountered inside the loop?
1. Control goes to next statement
2. Control goes to next statement after the loop
3. Program will stop unexpectedly
4. Skip the current statement and continue with next statement
Ans. 2

14. _____ statement is used to skip statement block and take the control at the
beginning for next iteration.
1. Break
2. Continue
3. Jump
4. None of above
Ans. 2

15. JavaScript is a ____based scripting language.


1. Object
2. Data
3. Variable
4. Datatype
Ans. 1

16. The ‘new’ keyword is used to create new _____ in JavaScript.


1. Object
2. Function
3. Variable
4. None of above
Ans. 1

17. DOM property “body” returns___ elements.


1. URL
2.
3. Title
4.
Ans. 4

18. Window object represents ____window in a browser.


1. Name of
2. Closed
3. Open
4. Status
Ans. 3

19. An object of window is created automatically by the___.


1. User
2. Server
3. Browser
4. None of above
Ans. 3

20. Which Window Object property is used to set the name of a window?
1. Document
2. Name
3. Status
4. Location
Ans. 2
21. Status Window Object property is used to set the text in the ____of a window.
1. Tool bar
2. Status bar
3. Title bar
4. Menu bar
Ans. 2

22. The Window Object Method____ displays the alert box containing message with
OK button.
1. prompt()
2. ALERT()
3. confirm()
4. blur()
Ans. 2

23. Which Window Object Method displays the confirm dialog box?
1. ALERT()
2. confirm()
3. blur()
4. focus()
Ans. 2

24. Which Window Object method is used to set focus to the current window?
1. prompt()
2. confirm()
3. blur()
4. focus()
Ans. 4

25. “onsubmit” event handler is used when user clicks ____button.


1. Cancel
2. Submit
3. Ok
4. None of above
Ans. 2

26. abs(X) math method is used to return _____ of number.


1. Cube
2. Square
3. Absolute
4. None of above.
Ans. 3

27. Date object can be created using ____ keyword.


1. Now
2. New
3. Create
4. None of above
Ans. 2

28. Date method getDate() is used to return the day of the ____.
1. Year
2. Month
3. Week
4. Both of above
Ans. 2

29. Which date method returns the minutes?


1. getSeconds()
2. getTime()
3. setMinutes()
4. getMinutes()
Ans. 4

30. Date setDate() Method is used to set the day of the ___ of a date object.
1. Month
2. Year
3. Weak
4. None of above
Ans. 1

31. JavaScript arrays are used to store multiple values in ___variable.


1. Double
2. Single
3. Both of above
4. None of above
Ans. 2

32. ____ is a special variable which can hold more than one value at a time.
1. Array
2. List
3. Number
4. String
Ans. 1

33. The index of the first element of an array is____.


1. One (1)
2. Zero(0)
3. Minus one (-1)
4. Any number.
Ans. 2

34. _______ scripts are used for validation purposes.


1. Website
2. Server side
3. Client side
4. Web browser
Ans. 3
35. All tangible things are known as ____.
1. Methods
2. Objects
3. Functions
4. Variables
Ans. 2

36. _____ array method is used to remove the last element of an array, and return
that element.
1. Push()
2. Pop()
3. Sort()
4. Reverse()
Ans. 2

You might also like