INTRODUCTION TO CLASSES AND METHODS ONE LINER 03
1) Which cast must be used to cast an object to another class?
Ans: Specific cast.
2) Which of the following features are common to both Java & C++?
A.The class declaration
Ans: Specific cast.
2) 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
c.The encapsulation of data & methods with in objects
d.The use of pointers
e. a, b , c
Ans: e
3) 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
f. a, b , d
Ans: f
4) 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.
5) Which of the following statements can be used to describe a public method?
a.It is accessible to all other classes in the hierarchy Java
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: b.
5) Which of the following statements can be used to describe a public method?
a.It is accessible to all other classes in the hierarchy Java
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
e. both a and c
Ans: e.
6) Which of the following types of class members can be part of the internal part of a class?
a.Public instance variables
Ans: e.
6) 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
c.Public methods
d.Private methods
e. both b and d
Ans: e.
7) You would use the ____ operator to create a single instance of a named class.
a.new
Ans: e.
7) You would use the ____ operator to create a single instance of a named class.
a.new
b.dot
Ans: a.
8) 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.
8) 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
e. a, b , c
Ans: e
9) If no input parameters are specified in a method declaration then the declaration will include __.
a.an empty set of parantheses
b.the term void
Ans: a.
10) 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.
10) 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
e. a, b , c
Ans: e
No comments:
Post a Comment