Object Oriented Programming - I (3140705) MCQs

MCQs of Object oriented thinking

Showing 21 to 30 out of 64 Questions
21.
Which of these is not a correct statement?
(a) Every class containing abstract method must be declared abstract
(b) Abstract class defines only the structure of the class not its implementation
(c) Abstract class can be initiated by new operator
(d) Abstract class can be inherited
Answer:

Option (c)

22.
Which of these packages contains abstract keyword?
(a) java.lang
(b) java.util
(c) java.io
(d) java.system
Answer:

Option (a)

23.
In order to restrict a variable of a class from inheriting to subclass, how variable should be declared?
(a) Protected
(b) Private
(c) Public
(d) Static
Answer:

Option (b)

24.
If super class and subclass have same variable name, which keyword should be used to use super class?
(a) super
(b) this
(c) upper
(d) classname
Answer:

Option (a)

25.
Which of the following is used for implementing inheritance through an interface?
(a) inherited
(b) using
(c) extends
(d) implements
Answer:

Option (d)

26.
Which of these class is used to create an object whose character sequence is mutable?
(a) String()
(b) StringBuffer()
(c) String() & StringBuffer()
(d) None of the mentioned
Answer:

Option (b)

27.
Which of this method of class StringBuffer is used to concatenate the string representation to the end of invoking string?
(a) concat()
(b) append()
(c) join()
(d) concatenate()
Answer:

Option (b)

28.
Which of these method of class StringBuffer is used to find the length of current character sequence?
(a) length()
(b) Length()
(c) capacity()
(d) Capacity()
Answer:

Option (a)

29.
What is the string contained in s after following lines of Java code?
StringBuffer s new StringBuffer("Hello");
s.deleteCharAt(0);
(a) Hell
(b) ello
(c) Hel
(d) llo
Answer:

Option (b)

30.
Which of the following statement is correct?
(a) reverse() method reverses all characters
(b) reverseall() method reverses all characters
(c) replace() method replaces first occurrence of a character in invoking string with another character
(d) replace() method replaces last occurrence of a character in invoking string with another character
Answer:

Option (a)

Showing 21 to 30 out of 64 Questions