Object Oriented Programming - I (3140705) MCQs

MCQs of Objects and Classes

Showing 1 to 10 out of 36 Questions
1.
What is the stored in the object obj in following lines of Java code?
   box obj;
(a) Memory address of allocated memory of object
(b) NULL
(c) Any arbitrary pointer
(d) Garbage
Answer:

Option (b)

2.
Which of these keywords is used to make a class?
(a) class
(b) struct
(c) int
(d) none of the mentioned
Answer:

Option (a)

3.
Which of the following is a valid declaration of an object of class Box?
(a) Box obj = new Box();
(b) Box obj = new Box;
(c) obj = new Box();
(d) new Box obj;
Answer:

Option (a)

4.
Which of these operators is used to allocate memory for an object?
(a) malloc
(b) alloc
(c) new
(d) give
Answer:

Option (c)

5.
Which keyword is used by the method to refer to the object that invoked it?
(a) import
(b) catch
(c) abstract
(d) this
Answer:

Option (d)

6.
What is not the use of “this” keyword in Java?
(a) Passing itself to another method
(b) Calling another constructor in constructor chaining
(c) Referring to the instance variable when local variable has the same name
(d) Passing itself to method of the same class
Answer:

Option (d)

7.
Arrays in Java are implemented as?
(a) class
(b) object
(c) variable
(d) none of the mentioned
Answer:

Option (b)

8.
Which of these keywords is used to prevent content of a variable from being modified?
(a) final
(b) last
(c) constant
(d) static
Answer:

Option (a)

9.
Which of the following statements are incorrect?
(a) Variables declared as final occupy memory
(b) final variable must be initialized at the time of declaration
(c) Arrays in java are implemented as an object
(d) All arrays contain an attribute-length which contains the number of elements stored in the array
Answer:

Option (a)

10.
What is the return type of Constructors?
(a) int
(b) float
(c) void
(d) none of the mentioned
Answer:

Option (d)

Showing 1 to 10 out of 36 Questions