
1. What is Typescript?
a) A scripting language
b) A superset of JavaScript
c) A programming language
d) A markup language
Answer: b
2. Which file extension is used for Typescript files?
a) .js
b) .ts
c) .html
d) .css
Answer: b
3. Which of the following is NOT a primitive type in Typescript?
a) number
b) string
c) boolean
d) object
Answer: d
4. Which keyword is used to declare a variable in Typescript?
a) var
b) let
c) const
d) All of the above
Answer: d
5. What is the difference between let and const keywords in Typescript?
a) let is used for variables that can be reassigned, while const is used for variables that cannot be reassigned
b) const is used for variables that can be reassigned, while let is used for variables that cannot be reassigned
c) let and const are interchangeable keywords
d) There is no difference between let and const in Typescript
Answer: a
6. Which Keyword is used to define a function in Typescript?
a) function
b) def
c) fn
d) All of the above
Answer: a
7. Which keyword is used to create an interface in Typescript?
a) interface
b) class
c) types
d) type
Answer: a
8. What is an interface in Typescript?
a) A blueprint for an object that describes its shape and properties
b) A function that returns a boolean value
c) An instruction to the Typescript compiler
d) A method for accessing object properties
Answer: a
9. Which keyword is used to create a class in Typescript?
a) class
b) interface
c) function
d) type
Answer: a
10. What is a class in Typescript?
a) A template for creating objects
b) A function that returns a value
c) A grouping of related variables
d) A way to organize code
Answer: a
11. Which keyword is used to extend a class in Typescript?
a) extends
b) expands
c) appliesTo
d) inherits
Answer: a
12. What is inheritance in Typescript?
a) The process of creating new classes from existing classes
b) The process of creating new variables from existing variables
c) The process of creating new interfaces from existing interfaces
d) The process of creating new functions from existing functions
Answer: a
13. What is polymorphism in Typescript?
a) The ability of an object to take multiple forms
b) The ability of a function to take multiple parameters
c) The ability of a variable to store multiple values
d) The ability of an interface to have multiple implementations
Answer: a
14. Which keyword is used to implement an interface in Typescript?
a) implements
b) appliesTo
c) integrates
d) extends
Answer: a
15. What is a module in Typescript?
a) A way to organize code into separate files
b) A way to create object instances
c) A way to define interfaces
d) A way to create classes
Answer: a
16. Which keyword is used to import a module in Typescript?
a) import
b) include
c) require
d) add
Answer: a
17. Which keyword is used to export a module in Typescript?
a) export
b) include
c) require
d) add
Answer: a
18. Which operator is used to declare a nullable variable in Typescript?
a) ?
b) !
c) #
d) *
Answer: a
19. Which operator is used to access a property of a nullable object in Typescript?
a) ?
b) !
c) #
d) *
Answer: b
20. Which built-in object is used for iterating over arrays in Typescript?
a) Array
b) ForEach
c) Iterator
d) None of the above
Answer: b
21. Which built-in object is used for iterating over objects in Typescript?
a) Object
b) ForEach
c) Iterator
d) None of the above
Answer: a
22. What is a namespace in Typescript?
a) A way to organize code into logical groups
b) A way to declare variables
c) A way to define interfaces
d) A way to create classes
Answer: a
23. What is an enum in Typescript?
a) A way to define a set of related constants
b) A way to define a set of related variables
c) A way to define a set of related interfaces
d) A way to define a set of related classes
Answer: a
24. Which keyword is used to declare an enum in Typescript?
a) enum
b) class
c) interface
d) type
Answer: a
25. Which of the following is NOT a valid access modifier in Typescript?
a) public
b) private
c) protected
d) final
Answer: d
26. What is a decorator in Typescript?
a) A special type of declaration that can be attached to a class declaration, method, accessor, property, or parameter
b) A way to access object properties
c) A way to define interfaces
d) A way to create classes
Answer: a
27. Which built-in decorator is used to mark a method or accessor as a getter?
a) @get
b) @getter
c) @getAccessor
d) @property
Answer: c
28. Which built-in decorator is used to mark a method or accessor as a setter?
a) @set
b) @setter
c) @setAccessor
d) @property
Answer: c
29. Which built-in decorator is used to mark a class as abstract?
a) @abstract
b) @abstractClass
c) @isAbstract
d) @class
Answer: a
30. What is an abstract class in Typescript?
a) A class that cannot be instantiated and serves as a base class for other classes
b) A class that can be instantiated and serves as a base class for other classes
c) A class that is marked with the @abstract decorator
d) A class that has all abstract methods
Answer: a
31. Which built-in decorator is used to mark a method or class as deprecated?
a) @deprecated
b) @deprecate
c) @obsolete
d) @old
Answer: a
32. What is a type assertion in Typescript?
a) A way to tell the compiler the type of a variable when Typescript cannot infer it
b) A way to access object properties
c) A way to define interfaces
d) A way to create classes
Answer: a
33. Which operator is used for type assertion in Typescript?
a) !
b) ?
c) #
d) *
Answer: a
34. What is a tuple in Typescript?
a) An array with a fixed number of elements and specified types for each element
b) An object with a fixed number of properties and specified types for each property
c) A type of variable that can store either a number or a string
d) A type of function that takes no arguments and returns nothing
Answer: a
35. Which built-in method is used to find the index of an element in an array in Typescript?
a) indexOf
b) findIndex
c) forEach
d) map
Answer: b
36. Which built-in method is used to find an element in an array in Typescript?
a) indexOf
b) findIndex
c) find
d) map
Answer: c
37. Which built-in method is used to filter elements from an array in Typescript?
a) filter
b) slice
c) map
d) reduce
Answer: a
38. Which built-in method is used to concatenate multiple arrays into a single array in Typescript?
a) concat
b) join
c) push
d) splice
Answer: a
39. What is a generic in Typescript?
a) A parameterized type that can be used to create reusable code
b) A function that returns a boolean value
c) A type of variable that can store either a number or a string
d) A type of function that takes no arguments and returns nothing
Answer: a
40. Which keyword is used to declare a generic type in Typescript?
a) generic
b) type
c) T
d) var
Answer: c
41. Which built-in function is used to iterate over the properties of an object in Typescript?
a) Object.keys()
b) Object.values()
c) Object.entries()
d) None of the above
Answer: c
42. Which built-in function is used to get the length of an array in Typescript?
a) array.length()
b) array.size()
c) array.count()
d) array.length
Answer: d
43. Which built-in function is used to sort an array in Typescript?
a) array.sort()
b) array.filter()
c) array.map()
d) None of the above
Answer: a
44. Which built-in function is used to reverse an array in Typescript?
a) array.reverse()
b) array.sort()
c) array.map()
d) None of the above
Answer: a
45. What is the difference between any and unknown types in Typescript?
a) any type allows any value, while unknown type requires a type assertion or type guard before being assigned
b) unknown type allows any value, while any type requires a type assertion or type guard before being assigned
c) any and unknown types are interchangeable
d) There is no difference between any and unknown types in Typescript
Answer: a
46. What is a type guard in Typescript?
a) A way to narrow down the type of a variable within a conditional statement
b) A way to access object properties
c) A way to define interfaces
d) A way to create classes
Answer: a
47. Which built-in function is used to convert a string to a number in Typescript?
a) parseInt()
b) parseFloat()
c) Number()
d) All of the above
Answer: d
48. Which built-in function is used to convert a number to a string in Typescript?
a) toString()
b) String()
c) toLocaleString()
d) All of the above
Answer: d
49. Which built-in function is used to align the decimal point in a number in Typescript?
a) toFixed()
b) toPrecision()
c) valueOf()
d) None of the above
Answer: a
50. What is a set in Typescript?
a) A collection of unique values of any type
b) A collection of ordered elements of any type
c) A collection of related methods and properties
d) None of the above
Answer: a
- Top 10 DevOps Trainers in the world - October 7, 2023
- What is Cookies and Why it is Used? - May 24, 2023
- TOP trends of transitions in TikTok - May 10, 2023