Web Designing MCQs

MCQ On JavaScript Types, Values And Variables Part-1

Pinterest LinkedIn Tumblr
This set of MCQ on JavaScript types, value and variables include MCQ on number, text or strings, Boolean, null and undefined values along with global and wrapper objects used in JavaScript. It also includes the difference between primitive values and mutable object reference, type conversions and equality in JavaScript.

1. The kind of values that can be represented and manipulated in a programming language are known as …………..
A) Types
B) Variables
C) Symbols
D) Constants

2. A ………………… defines a symbolic name for a value and allows the value to be referred to by name.
A) Types
B) Variables
C) Symbols
D) Constants

3. JavaScript’s ………………. types include numbers, strings or text and Boolean truth values.
A) standard
B) variable
C) object
D) primitive

4. The special JavaScript values null and undefined are ……………. values, but they are not numbers, strings or booleans.
A) standard
B) variable
C) object
D) primitive

5. In JavaScript ………………. are the only values that methods cannot be invoked on.
i) numbers   ii) strings   iii) null   iv) booleans  v) undefined
A) i and ii only
B) ii and iii only
C) iii and iv only
D) iii and v only

6. In which of the following JavaScript type, a JavaScript program can change  the values of object properties.
A) Numbers
B) Booleans
C) Objects
D) Null

7. State whether the following statements about JavaScript types are True or False
i) JavaScript variables are untyped
ii) Numbers, Boolean and null and undefined are immutable
A) i-True, ii-True
B) i-True, ii-False
C) i-False, ii-True
D) i-False, ii-False

8. ……………….. in JavaScript returns infinity or negative infinity.
A) Division by zero
B) Zero divided by zero
C) Division by infinity
D) Infinity divided by infinity

9. ……………. does not return any well defined value, and the result of operation in the special not a number value which is printed as NaN.
i) Division by zero ii) Zero divided by zero iii) Division by infinity  iv) Infinity divided by infinity
A) i and ii only
B) ii and iii only
C) ii and iv only
D) i and iv only

10. JavaScript predefined global variables ……………. to hold the positive infinity and not a number value.
i) infinity    ii) zero   iii) NaN   iv) Number
A) i and ii only
B) ii and iii only
C) ii and iv only
D) i and iii only

11. Which of the following expression evaluates to infinity.
A) 1 / infinity
B) Number.POSITIVE_INFINITY
C) 1 / 0
D) 0 / 0

12. Which of the following expression evaluates negative infinity.
A) -1 / Infinity
B) -0
C) -1 / 0
D) -Number.MIN_VALUE-1

13. State whether the following statements about about arithmetic operators are True or False
i)  Zero and negative zero are equal   ii) Infinity and negative infinity are not equal  iii) -1 / Infinity evaluates negative infinity
A) True, True, True
B) True, False, False
C) False, True, False
D) True, True, False

14. …………….. gives an initial set of properties that define constructor functions like Date(), ReExp(), String(), Object() and Array().
A) Local object
B) Global object
C) Wrapper object
D) Boolean object

15. The temporary objects create when you access a property of a string, number or boolean are known as . …………………..
A) Local object
B) Global object
C) Wrapper object
D) Boolean object

16. There are two objects with the same properties var O={x:1}, P={x:1}; If we evaluate them using O= = = P, It results
A) True
B) False
C) Undefined
D) Error

17. There is a variable a refers to an empty array, var a=[ ]; If b=a; and b[0]=1; what will be the value of a[0].
A) Empty Array
B) 1
C) 0
D) Undefined

18. When null value is converted into number in JavaScript, it returns
A) null
B) 0
C) false
D) throwsTypeError

19. When infinity value is converted into Boolean in JavaScript it returns.
A) True
B) False
C) Infinity
D) Undefined

20. If we compare “0” = = false in JavaScript, how it will compare.
A) Two values treated as equal without converting
B) String converts to the number before comparing
C) Boolean converts to the number before comparing
D) Both operands convert to numbers before comparing

Answers

1. A) Types
2. B) Variables
3. D) primitive
4. D) primitive
5. D) iii and v only
6. C) Objects
7. A) i-True, ii-True
8. A) Division by zero
9. C) ii and iv only
10. D) i and iii only
11. B) Number.POSITIVE_INFINITY
12. C) -1 / 0
13. D) True, True, False
14. B) Global object
15. C) Wrapper object
16. B) False
17. B) 1
18. B) 0
19. A) True
20. D) Both operands convert to numbers …

Read Next: MCQ On JavaScript Types, Values And Variables Part-2

Author

Shuseel Baral is a web programmer and the founder of InfoTechSite has over 8 years of experience in software development, internet, SEO, blogging and marketing digital products and services is passionate about exceeding your expectations.

Comments are closed.