Core Java - Interview Questions and Answers

171. Casting does not affect the original object or value.

a)True
b)False
Ans: a.

172. Which cast must be used to convert a larger value into a smaller one?

Ans: Explicit cast.

173. Which cast must be used to cast an object to another class?

Ans: Specific cast.

174. 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.

175. 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.

176. Suppose a given instance variable has been declared private.
Can this instance variable be manipulated by methods out side its class?

a.yes
b.no
Ans: b.

177. Which of the following statements can be used to describe a public method?

a.It is accessible to all other classes in the hierarchy
b.It is accessablde only to subclasses of its parent class
c.It represents the public interface of its class
d.The only way to gain access to this method is by calling one of the public class
methods
Ans: a,c.

178. Which of the following types of class members can be part of the internal part of a class?

a.Public instance variables
b.Private instance variables
c.Public methods
d.Private methods
Ans: b,d.

179. You would use the ____ operator to create a single instance of a named class.

a.new
b.dot
Ans: a.

180. Which of the following statements correctly describes the relation between an object and the instance variable it stores?

a.Each new object has its own distinctive set of instance variables
b.Each object has a copy of the instance variables of its class
c.the instance variable of each object are seperate from the variables of other objects
d.The instance variables of each object are stored together with the variables of other objects
Ans: a,b,c.


Post a Comment

Mới hơn Cũ hơn