161. How can class be imported to a program?
Ans: To import a class, the import keyword should be used as shown.;
import classname;
162. How can class be imported from a package to a program?
Ans: import java . packagename . classname (or) import java.package name.*;
163. What is a constructor?
Ans: A constructor is a special kind of method that determines how an object is
initialized when created.
164. Which keyword is used to create an instance of a class?
Ans: new.
165. Which method is used to garbage collect an object?
Ans: finalize ().
166. Constructors can be overloaded like regular methods.
a)True
b)False
Ans: a.
167. What is casting?
Ans: Casting is bused to convert the value of one type to another.
168. Casting between primitive types allows conversion of one primitive type to another.
a)True
b)False
Ans: a.
169. Casting occurs commonly between numeric types.
a)True
b)False
Ans: a.
170. Boolean values can be cast into any other primitive type.
a)True
b)False
Ans: b.
0 Comments