Classes and Methods

17) Casting occurs commonly between numeric types.



Ans: a.

18) Boolean values can be cast into any other primitive type.



Ans: b.

19) Casting does not affect the original object or value.



Ans: a.

20) Which cast must be used to convert a larger value into a smaller one?

Ans: Explicit cast.

21) Which cast must be used to cast an object to another class?

Ans: Specific cast.

22) Which of the following features are common to both Java & C++?

A.The class declaration

b.The access modifiers

c.The encapsulation of data & methods with in objects

d.The use of pointers

Ans: a,b,c.

23) Which of the following statements accurately describe the use of access modifiers within a class definition?

a.They can be applied to both data & methods

b.They must precede a class’s data variables or methods

c.They can follow a class’s data variables or methods

d.They can appear in any order

e.They must be applied to data variables first and then to methods

Ans: a,b,d.

24) Suppose a given instance variable has been declared private.

Can this instance variable be manipulated by methods out side its class?


Ans: b.

Ref Link contributor :

Permanent link to Java Tutorials / Java Interview Questions: