Professional Documents
Culture Documents
MCQ Typescript
MCQ Typescript
BCSF13M004
BCSF13M036
1. Which of the following is valid command to compile typescript file?
a. ts abc.ts
b. t abc.ts
c. tsc abc.ts
d. tst abc.ts
2. Which is not true about typescript?
a. It is interpreted like javascript
b. It is a superset of javascript
c. It does support static data types
d. Typescript is case sensitive
3. Which of the following is valid typescript statement?
a. var string a=”Hello”;
b. string a=”Hello”;
c. var a:string=”Hello”;
d. var a=”Hello”:string;
4. Which statement does yield error in typescript?
a. var a=”Hello”;
b. var a:string;
c. var b:number=12;
d. var a:string=12;
5. What will be output of :
var a:string=47; console.log(“Value of a= ”+a);
a. Value of a=47
b. Value of a=0
c. Value of a=
d. None of the above
6. Which of the following function definition is correct in typescript?
a. number function abc(string a){return 12;}
b. function abc(string a,number b){return 12;}
c. both a and b
d. none of the above
7. var a=function():number{
return 12;
};
What is type of a?
a. number
b. int
c. both a and b
d. none of the above
8. class keyword is:
a. a feature of typescript
b. feature of javascript
c. both a and b
d. none of the above
9. class Bird {
Bird () {
console.log(“I am Bird”);
}
10.
11.
12.
13.
14.
}
What will be output of : var obj=new Bird();?
a. Error
b. I am Bird
c. Bird am I
d. None of these
class MyClass {
var a=12;
}
var obj=new MyClass();
console.log(“Value of a= ”+a);
What is the output of above code?
a. Error
b. Value of a =12
c. A is private and cannot be accessed
d. None of the above
Class MyClass{
a:number;
func(){
}
}
Which of following is true?
a. func is public and a is private
b. func is public and a is protected
c. both are public
d. both are private
Which of the following is not true about typescript?
a. It supports inheritance.
b. It supports abstract classes.
c. It supports interfaces.
d. None of the above.
Which of the following is correct syntax for making a static variable in
typescript?
a. static st:string;
b. st:string:static;
c. static(st:string);
d. none of the above
Which of the following is correct way of inheriting in typescript?
a. class B:A{}
b. class B inherits A{}
c. class B: class A{}
15.
16.
17.
18.
19.
20.
c
a
c
d
d (As there is an error in line 1 of the code)
d
d (As a have type function)
c
d (constructor keyword is used to built constructor and not a function with same
name as class)
a (var cannot be used inside class)
c
d
b
d
d (Transpiller)
d (error cannot convert number to string)
a
c
a
d
References:
https://www.typescriptlang.org/