Std12e ch8
Std12e ch8
Std12e ch8
4. When a program contains 2 or more classes, only one class can contain the
…………method.
a) main( ) b) String( ) c) class d) private
1
15. Which operator allocates the memory for an object and returns the address of
object?
a) new b) object c) class d) Method
16. What do we call the address of the memory location where the object is stored?
a) Address b) Reference c) Allocated d) Constant
17. What do we call the special portion of memory where the objects live?
a) Reference b) Heap c) Address d) Structure
18. When an object is created, then which special method is executed to perform
initial task?
a) Constructor b) Method c) Attributes d) Function
20. When statement “r1=new Room( );” is executed then what is stored in r1?
a) Address of an object b) Reference of an object
c) Heap d) All of these
21. Which of the following is the correct syntax to declare and create an object in a
single line?
a) Room r2=new Room( ); b) room r=room();
c) Room r1=room() d) Room =Room(new);
22. In Java, which of the following looks for unused objects and reclaims the memory
that those objects are using?
a) Variable collector b) Garbage collector
c) Class collector d) Object collector
23. In Java, creating an object with „new‟ key word is also called object ……………..
a) Declaration b) Instantiation c) Initialization d) All of these
24. Which type of variables is created at the time of creating an object and stay
throughout the life of the ojects ?
a) Local b) Instance c) Static d) null
27. All instance of class are allocated memory in which data structure?
a) heap b) constructor c) Inherit d) Overload
28. Write down the syntax of accessing and calling instance variable.
Ans. <object reference> . <instance variable or method>
2
29. What is the associativity of dot operator?
a) L to R b) R to L c) T to B d) B to T
31. Referring instance variable or invoking method with null reference will give
………...
a) output b) Error c) Object d) Class
34. Which variables are called the class variable can be declared within class using
static keyword before data type ?
a) Memory b) static c) local d) instance
35. What do we call the variables that defined inside methods or blocks?
a) Local variable b) Class variable c) Static variable d) Instance variable
36. What do we call the variables that are defined within a class but outside any
method?
a)Instance variable b) Class variable c) Static variable d) Local variable
38. What do we call the term where different forms of methods are used with same
name?
a) Polymorphism b) Inheritance c) constructor d) Aggregation
40. Which term means, different methods that have the same name but a different
signature?
a) Method overloading (b) Inheritance c) Constructor d) Aggregation
42. What do we call the special method that is invoked when a new object is created?
a) Polymorphism b) Constructor c) Inheritance d) All of these
3
43. Every class is having its default ……………
a) Polymorphism b) Constructor c) Inheritance d) All of these
50. In absence of user define constructor in a class, objects are constructed using
which type of constructor?
a) Default b) no – argument c) Parameterized d) multilevel
55. Which of the following is not a part of Four P‟s protection in Java?
a) public b) package c) private d) provided
4
56. Which type of access modifiers are used before the type of variable or method?
a) public b) protected c) private d) All of these
59. Which access modifier provides visibility to classes defined in the other package?
a) public b) package c) Private d) Protected
60. To provide public access, which keyword type before method or variable type?
a) Private b) Public c) Protected d) Package
66. Which level of protection is used to allow the access only to subclasses or to share
with the methods declared as “friend”?
a) public b) protected c) Private d) Package
5
69. If we want private data to be used by other, then which method is used?
a) accessor b) access c) excess d) mutator
70. If we want to allow private data to be modified by others, then which method is
used?
a) accessor b) access c) excess d) mutator
71. Which of the following prefix is utilize for conventionally naming of mutator
method?
a) wait b) set c) get d) take
72. Which of the following prefix is utilize for conventionally naming of accessor
method?
a) wait b) set c) get d) take
73. If we want to allow other methods to read only the data value, then which method
is used?
a) getter b) get c) set d) setter
74. If we want to allow other methods to modify the data value, then which method is
used?
a) getter b) get c) set d) setter
75. Find the valid getter or setter names from the list.
(1) getLength (2) GetLength (3) getlength (4) setLength (5)SetLength (6)
setAttribute
a) 1,3,4,6 b) 1,4,6 c) 1,2,3,4 d) 1,3,4,6
76. Which facility allows us to build new class with added capabilities by extending
existing class?
a) Inheritance b) Constructor c) Polymorphism d) Aggregation
77. Inheritance model is based on which type of relationship between two classes?
a) has - a – part b) is – a – kind c) is-a-kind-of d) both b or c
81. Which class inherits all instance variables and methods from super class, and it
may have its own added variables and methods?
a) Base class (b) Subclass c) Sub class d) None of above
6
82. What is not inherited in sub class?
a) Constructor b) Method c) Polymorphism d) Super class
84. Which keyword is used to call the constructor of super class in the constructor of
sub class?
a) extends b) super c) extends d) new
85. When super class and sub class have methods with same signature, a super class
method is said to
be ………….. in the sub class.
a) overloading b) overridden c) operator loading d) None of above
86. All instance variable and methods are inherited from super class to
…………..class.
a) sub b) Parent c) super d) new
89. Which of the following are the construction of classes that incorporate other
objects. They establish
a “has-a” relationship between classes?
a) Composition b) aggregation c) Constructor d) Both a or b
90. Composition & aggregation establish which type of relationship between classes?
a) has – a – part b) has – a c) is-a-kind-of d) Both a or b
Textbook Exercise
2. Which of the following keyword is used to declare class variables and class
methods?
a) static b) private c) public d) package
3. Which of the following operator creates an object and returns its reference?
a) dot ( . ) b) new c) colon ( : ) d) assignment (=)
7
4. Which method can be called without creating an instance of a class?
a) Instance method b) Class Method c) Constructor method d) All of the above
5. Which of the following refers more than one method having same name but
different parameters?
a) Overloaded methods b) Overridden methods
c) Duplicate methods d) All
10. When method in the superclass and subclass have same name and signature,
what are they called?
a) Overloaded methods b) Inherited methods
c) Inherited methods d) All of the above.