Classes and Methods

25) 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.

hudihudi.com

26) 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.

hudihudi.com

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

a.new

b.dot

Ans: a.

28) 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 separate 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.

hudihudi.com

29) If no input parameters are specified in a method declaration then the declaration will include __.

a.an empty set of parentheses

b.the term void

Ans: a.

30) What are the functions of the dot(.) operator?

a.It enables you to access instance variables of any objects within a class

b.It enables you to store values in instance variables of an object

c.It is used to call object methods

d.It is to create a new object

Ans: a,b,c.

hudihudi.com

31) Which of the following can be referenced by this variable?

a.The instance variables of a class only

b.The methods of a class only

c.The instance variables and methods of a class

Ans: c.

hudihudi.com

32) The this reference is used in conjunction with ___methods.

a.static

b.non-static

Ans: b.

hudihudi.com

33) Which of the following operators are used in conjunction with the this and super references?

a.The new operator

b.The instance of operator

c.The dot operator

Ans: c.

Ref Link contributor : http://www.hudihudi.com/placement/java/java21.htm

Permanent link to Java Tutorials / Java Interview Questions: http://www.freshersinterviewquestions.com/java-classes-and-methods/