LATEST

Wednesday, April 29, 2020

INTRODUCTION TO CLASSES AND METHODS ONE LINER 02

INTRODUCTION TO CLASSES AND METHODS ONE LINER 02

1) What is a constructor? 
Ans: A constructor is a special kind of method that determines how an object is initialized when created.

2) Which keyword is used to create an instance of a class?
Ans: new.

3) Which method is used to garbage collect an object?
Ans: finalize ().

4) Constructors can be overloaded like regular methods.
a)True          
b)False
Ans: a.

5) What is casting?
Ans: Casting is bused to convert the value of one type to another.

6) Casting between primitive types allows conversion of one primitive type to another.
a)True                
b)False
Ans: a.

7) Casting occurs commonly between numeric types.
a)True              
b)False
Ans: a.

8) Boolean values can be cast into any other primitive type.
a)True              
b)False
Ans: b.

9) Casting does not affect the original object or value.
a)True               
b)False
Ans: a.

10) Which cast must be used to convert a larger value into a smaller one?
Ans: Explicit cast.

No comments:

Post a Comment