Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Chapter – 8 Class and Object in Java - 50 Marks MCQ

1. Which of the following defines attributes and methods?


(A) Class (B) Object (C) Instance (D) Variable
A
2. In Java, a class is generally made up of which components?
(A) Behaviour, Variable (B) Attributes, Behaviour
(C) Name, Attributes (D) Class, Variable
B
3. In Java, a class is defined using which keyword?
(A) class (B) Class (C) CLASS (D) All of these
A
4. In Java, which step is followed to create an object form a class?
(D) Declaration (B) Instantiation (C) Initialization (D) All of these
D
5. In Java, which step a „new‟ keyword is used to create the object by allocating memory?
(A) Declaration (B) Instantiation (C) Initialization (D) All of these
B
6. In Java, which step of creating an object from a class initialize the newly created object?
(A) Declaration (B) Instantiation (C) Initialization (D) All of these
C
7. In Java, which keyword is used to create the object by allocating memory?
(A) super (B) new (C) class (D) add
B
8. Which of the following operator creates an object and returns its reference?
(A) dot (.) (B) new (C) object (D) class
B
9. All instances of class are allocated memory in data structure is called what?
(A) Zeep (B) Leap (C) Heap (D) Reap
C
10. A variable declared using class type can store what to an object?
(A) variable (B) class (C) heap (D) reference
D
11. In Java, who looks for unused objects and reclaims the memory?
(A) Unused collector (B) Object collector (C) Reclaim collector (D) Garbage collector
D
12. In Object-oriented programming languages, creating an object is also called as what?
(A) Objet instantiation (B) Object installation
(C) Object creation (D) Object making
13. In Java class, which operator is used to access instance variable and instance method via
object?
(A) : (colon) (B) ; (semicolon) (C) .(dot) (D) , (comma)
C
14. What is the associativity of .(dot) operator which is used to access instance variable?
(A) Lower to Upper (B) Upper to Lower (C) Left to Right (D) Right to Left
C
15. Which of the following keyword is used to declare Class variables and Class methods?
(A) static (B) class (C) variable (D) object
A
16. Which of the following method can be called without creating an instance of a class?
(A) Instance method (B) Class method
(C) Constructor method (D) All of these
B
17. Which of the following represents the type of variable?
(A) Local variables (B) Instance variables (C) Class variables (D) All of these
D
18. Which type of variable are defined inside methods or blocks?
(A) Local variables (B) Instance variables (C) Class variables (D) All
A
19. Which type of variables are defined within a class but outside any method?
(A) Local variables (B) Instance variables (C) Class variables (D) All
B
20. Which type of variables are defined with in a class, outside any method with the „static‟
keyword?
(A) Local variables (B) Instance variables (C) Class variables (D) All
C
21. In Java, which keyword is used to declare Class variable?
(A) static (B) var (C) new (D) class
A
22. Which of the following is the meaning of Polymorphism?
(A) Single form (B) Many forms (C) Virtual forms (D) User forms
B
23. Which word means “many forms”, different forms of methods with same name in Java?
(A) Inheritance (B) Polymorphism (C) Aggregation (D) Composition
B
24. In Java, which of the following refers to different methods that have the same name but a
different signature?
(A) Method overloading (B) Variable overloading
(C) Class overloading (D) Signature overloading
A
25. Which method is invoked automatically with creation of an object?
(A) Instance (B) Constructor (C) Class (D) Object
B
26. Which of the following is a special kind of method that is invoked when a new object is
created?
(A) Constructor (B) Class (C) Object (D) Instance
A
27. How to define user define no-argument constructor?
(A) Room [ ] { }; (B) Room < > ( ); (C) Room ( ) { }; (D) Room { } ( );
C
28. In Java, how many levels of visibility modifiers are available for access control?
(A) 2 (B) 3 (C) 4 (D) 5
C
29. Which are the for P‟s used in the four levels of visibility to provide necessary protection?
(A) Process, Private, Protected, Public (B) Public, Package, Protected, Private
(C) Public, Package, Protected, Process (D) Private, Package, Protected, Public
B
30. In we want to make visible to all the classes outside the class, where method or variable is
visible to class, which type of access modifier is used?
(A) Protected (B) Package (C) Public (D) Private
C
31. Which is the default level of protection, where lack of any access modifier keyword is in a
declaration in Java?
(A) Protected (B) Package (C) Public (D) Private
B
32. Which of the following is syntax of package?
(A) Package {Package Name}; (B) Package (Package Name);
(C) Package [Package Name]; (D) Package <Package Name>;
D
33. Which level of protection is used to allow the access only to sub classes or to share with the
methods declared as “friend” in Java?
(A) Protected (B) Package (C) Public (D) Private
A
34. Which of the following is the highest level of protection in Java?
(A) Provided (B) Package (C) Public (D) Private
D
35. If we want to allow such data to be used by others, then which method is used?
(A) Access (B) Mutor (C) Accessor (D) Mutator
C
36. Which of the following prefix is utilize for conventionally naming of Accessor and Mutator
method respectively?
(A) get, set (B) set, get (C) get, post (D) post, get
A
37. Accessor method is known as what in Java?
(A) set (B) get (C) setter (D) getter
D
38. If we want to allow other methods to read only the data value, then which method is used?
(A) reader (B) writer (C) setter (D) getter
D
39. If we want to allow such data to be modified by others, then which method is used?
(A) Access (B) Mutor (C) Accessor (D) Mutator
D
40. Mutator method is known as what in Java?
(A) set (B) get (C) setter (D) getter
C
41. If we want to allow other methods to modify the data value, then which method is used?
(A) reader (B) writer (C) setter (D) getter
C
42. Which of the following in Object-oriented programming language provide reusability feature?
(A) Objection (B) Constructors (C) Polymorphism (D) Inheritance
D
43. Which of the following allows us to build new class with added capabilities by extending
existing class?
(A) Inheritance (B) Polymorphism (C) Aggregation (D) Composition
A
44. In Inheritance models consist of which type of relationship between two classes?
(A) is – a (B) has – a (C) have – a (D) was – a
A
45. In Java, Child class can be referred to as which of the following?
(A) Sub class, Derived class, Extended class (B) Sub class, Super class, Base Class
(C) Sub class, Base class, Super class (D) Parent class, Extended class, Base class
A
46. In Java, Parent class can be referred to as which of the following?
(A) Sub class, Derived class, Extended class (B) Parent class, Super class, Base Class
(C) Sub class, Base class, Super class (D) Parent class, Extended class, Base class
B
47. In Java, a Sub class inherits all instance variables and methods from which class?
(A) Derived class (B) Extended class (C) Super class (D) Child class
C
48. In Java, a Sub class can be derived from which class?
(A) Child class (B) Super class (C) Extended class (D) Owner class
B
49. In Java, which keyword is used to call the constructor of super class in the constructor of sub
class?
(A) super (B) extends (C) sub (D) class
A
50. In Java, Composition and Aggregation establish which type of relationship between classes?
(A) has – a (B) is – a (C) was – a (D) as – a

==========

You might also like