Object Oriented Programming - I (3140705) MCQs

MCQs of Exception Handling, I/O, abstract classes and interfaces

Showing 21 to 30 out of 38 Questions
21.
Which of these statements is incorrect?
(a) try block need not to be followed by catch block
(b) try block can be followed by finally block instead of catch block
(c) try can be followed by both catch and finally block
(d) try need not to be followed by anything
Answer:

Option (d)

22.
Which of these methods return description of an exception?
(a) getException()
(b) getMessage()
(c) obtainDescription()
(d) obtainException()
Answer:

Option (b)

23.
Which of these methods is used to print stack trace?
(a) obtainStackTrace()
(b) printStackTrace()
(c) getStackTrace()
(d) displayStackTrace()
Answer:

Option (b)

24.
Which of these methods return localized description of an exception?
(a) getLocalizedMessage()
(b) getMessage()
(c) obtainLocalizedMessage()
(d) printLocalizedMessage()
Answer:

Option (a)

25.
Which of these keywords is used to define interfaces in Java?
(a) interface
(b) Interface
(c) intf
(d) Intf
Answer:

Option (a)

26.
Which of these can be used to fully abstract a class from its implementation?
(a) Objects
(b) Packages
(c) Interfaces
(d) None of the Mentioned
Answer:

Option (c)

27.
Which of these access specifiers can be used for an interface?
(a) Public
(b) Protected
(c) private
(d) All of the mentioned
Answer:

Option (a)

28.
Which of these keywords is used by a class to use an interface defined previously?
(a) import
(b) Import
(c) implements
(d) Implements
Answer:

Option (c)

29.
Which of the following is the correct way of implementing an interface salary by class manager?
(a) class manager extends salary {}
(b) class manager implements salary {}
(c) class manager imports salary {}
(d) none of the mentioned
Answer:

Option (b)

30.
Which of the following is an incorrect statement about packages?
(a) Interfaces specifies what class must do but not how it does
(b) Interfaces are specified public if they are to be accessed by any code in the program
(c) All variables in interface are implicitly final and static
(d) All variables are static and methods are public if interface is defined pubic
Answer:

Option (d)

Showing 21 to 30 out of 38 Questions