Sei sulla pagina 1di 6

TYPESCRIPT

A brief introduction to 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.

d. class B extends A{}


e. class B extends class A{}
Program that converts a code from one high level language to another high level language is
called
a. Compiler
b. Decompiler
c. Inter translator
d. None of the above
What will be the output of following in typescript?
var a=12;
a=Yes;
console.log(a);
a. 12
b. Yes
c. 12Yes
d. None of the above
function abc(a:string){
console.log(a);
}
What will be the output of : abc();
a. Error
b. NULL
c.
d. None of the above
What is role of constructor keyword?
a. No such keyword exists in typescript.
b. Is used to call constructor of an instance.
c. Is used to define constructor for class.
d. None of the above.
Can we use alert() in typescript?
a. Yes
b. No
Class A{
var abc:number;
}
What is the error in above code?
a. No Error
b. There must be a constructor
c. There must be ; at end of the class
d. var should not be used inside class

Answers:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
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/

Potrebbero piacerti anche