Test Preperation (Part 2)
Test Preperation (Part 2)
Test Preperation (Part 2)
Exam Preperation
(Part 02)
26. What keyword is used to declare a variable in TypeScript?
a) var
b) let
c) const
d) Both b) and c)
a) var
b) let
c) const
d) Both a) and b)
Answer: b) let
28. What is the key difference between var, let, and const in JavaScript/TypeScript?
b) var has block scope, while let and const have function scope.
c) var has function scope, while let and const have block scope.
d) let and const are used for declaring functions, while var is used for variables.
Answer: c) var has function scope, while let and const have block scope.
29. Which of the following is true about TypeScript's type inference for variables?
Answer: b) TypeScript infers variable types based on the initial value assigned.
31. In TypeScript, what is the scope of a variable declared using the var keyword?
a) Global scope
b) Function scope
c) Block scope
d) Module scope
a) Type assertions
b) Type inference
c) Type narrowing
d) Type annotations
34. What happens if you try to redeclare a variable using let or const in the same scope
in JavaScript/TypeScript?
35. Which of the following statements is true regarding let and const in
JavaScript/TypeScript?
a) $
b) @
c) #
d) &
Answer: a) $
a) my-variable
b) 1stVariable
c) var#
d) _myVariable
Answer: d) _myVariable
39. In Typescript, which of the following is a common convention for naming variables
with multiple words?
d) Both b) and c)
a) numofstudents
b) numOfStudents
c) num_of_students
d) NumOfStudents
Answer: b) numOfStudents
a) +
b) -
c) *
d) /
Answer: a) +
42. In Typescript, what is the result of the following expression: "Hello" + " " +
"World"?
a) HelloWorld
b) Hello World
c) “HelloWorld”
d) SyntaxError
a) .
b) :
c) ;
d) ,
Answer: c) ;
44. Which of the following is the correct syntax for declaring a variable in Typescript?
b) myVar = 10;
b) Concatenating strings.
c) Backticks (` `)
d) Square brackets ([ ])
Answer: c) Backticks (` `)
47. Which of the following expressions correctly uses template literals in TypeScript?
a) `Hello, ${name}!`
b) "Hello, ${name}!"
c) 'Hello, ${name}!'
d) [Hello, ${name}!]
48. What advantage do template literals offer over traditional string concatenation in
TypeScript?
b) They allow for the interpolation of variables directly into the string.
Answer: b) They allow for the interpolation of variables directly into the string.
a) number
b) boolean
c) array
d) string
Answer: c) array
51. What is the data type of the following variable declaration in TypeScript: let age =
25;?
a) string
b) number
c) boolean
d) array
Answer: b) number
a) :
b) =
c) <>
d) !
Answer: a) :
Answer: b) To automatically determine the data type of a variable based on its value.
55. In statically typed languages like TypeScript, when are type errors typically
detected?
a) During compilation.
b) During runtime.
a) To execute code.
c) To declare variables.
d) To define functions.
a) //
b) #
c) ;
d) /*
Answer: a) //
a) To declare variables.
c) To define functions.
d) To document code.
a) &&
b) ||
c) +
d) !
Answer: c) +
62. What does the === operator do in TypeScript?
c) It performs addition.
d) It performs assignment.
c) It performs subtraction.
d) It performs assignment.
b) To compare values.
d) To declare variables.
a) +
b) &&
c) +
d) *
Answer: b) &&
66. What is the result of the logical AND (&&) operator when both operands are true?
a) true
b) false
c) null
d) undefined
Answer: a) true
67. What is the result of the logical OR (||) operator when one operand is true and the
other is false?
a) true
b) false
c) null
d) undefined
Answer: a) true
a) +
b) +=
c) ||
d) /
Answer: c) ||
d) To define a function.
70. When is the "else" statement used in conjunction with the "if" statement?
d) To define a function.
a) To execute a block of code only if a specified condition is true, and to execute another
block of code if that condition is false.
c) To execute a block of code only if the preceding "if" condition is false and a new condition
is true.
d) To define a function.
Answer: c) To execute a block of code only if the preceding "if" condition is false and a
new condition is true.
Answer: b) To watch for changes in TypeScript files and automatically recompile them.