Explore topic-wise MCQs in Technical Programming.

This section includes 1671 Mcqs, each offering curated multiple-choice questions to sharpen your Technical Programming knowledge and support exam preparation. Choose a topic below to get started.

1301.

Which of these method of class String is used to obtain length of String object?

A. get()
B. Sizeof()
C. lengthof()
D. length()
Answer» E.
1302.

Which of these operators can be used to concatenate two or more String objects?

A. +
B. +=
C. &
D. ||
Answer» B. +=
1303.

Which of these class is superclass of String and StringBuffer class?

A. java.util
B. java.lang
C. ArrayList
D. None of the mentioned
Answer» C. ArrayList
1304.

Does Java support multiple level inheritance?

A. True
B. False
Answer» B. False
1305.

What would be the result if class extends two interfaces and both have method with same name and signature?

A. Runtime error
B. Compile time error
C. Code runs successfully
D. First called method is executed successfully
Answer» C. Code runs successfully
1306.

Which of the following is used for implementing inheritance through class?

A. inherited
B. using
C. extends
D. implements
Answer» D. implements
1307.

Which of the following is used for implementing inheritance through interface?

A. inherited
B. using
C. extends
D. implements
Answer» E.
1308.

Static members are not inherited to subclass.

A. True
B. False
Answer» C.
1309.

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» B. this
1310.

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» C. Public
1311.

All classes in Java are inherited from which class?

A. java.lang.class
B. java.class.inherited
C. java.class.object
D. java.lang.Object
Answer» E.
1312.

Using which of the following, multiple inheritance in Java can be implemented

A. Interfaces
B. Multithreading
C. Protected methods
D. Private methods
Answer» B. Multithreading
1313.

What is not type of inheritance?

A. Single inheritance
B. Double inheritance
C. Hierarchical inheritance
D. Multiple inheritance
Answer» C. Hierarchical inheritance
1314.

What is the output of this program? class A { public int i; public int j; A() { i = 1; j = 2; } } class B extends A { int a; B() { super(); } } class super_use { public static void main(String args[]) { B obj = new B(); System.out.println(obj.i + " " + obj.j) } }

A. 1 2
B. 2 1
C. Runtime Error
D. Compilation Error
Answer» B. 2 1
1315.

What is the output of this program? class A { public int i; private int j; } class B extends A { void display() { super.j = super.i + 1; System.out.println(super.i + " " + super.j); } } class inheritance { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); } }

A. 2 2
B. 3 3
C. Runtime Error
D. Compilation Error
Answer» E.
1316.

What is the output of this program? class A { int i; } class B extends A { int j; void display() { super.i = j + 1; System.out.println(j + " " + i); } } class inheritance { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); } }

A. 2 2
B. 3 3
C. 2 3
D. 3 2
Answer» D. 3 2
1317.

What is the output of this program? class A { int i; void display() { System.out.println(i); } } class B extends A { int j; void display() { System.out.println(j); } } class inheritance_demo { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); } }

A. 0
B. 1
C. 2
D. Compilation Error
Answer» D. Compilation Error
1318.

Which two classes use the Shape class correctly? A. public class Circle implements Shape { private int radius; } B. public abstract class Circle extends Shape { private int radius; } C. public class Circle extends Shape { private int radius; public void draw(); } D. public abstract class Circle implements Shape { private int radius; public void draw(); } E. public class Circle extends Shape { private int radius; public void draw() { /* code here */ } } F. public abstract class Circle implements Shape { private int radius; public void draw() { /* code here */ } }

A. B,E
B. A,C
C. C,E
D. T,H
Answer» B. A,C
1319.

Which of these is correct way of inheriting class A by class B?

A. class B + class A {}
B. class B inherits class A {}
C. class B extends A {}
D. class B extends class A {}
Answer» D. class B extends class A {}
1320.

A class member declared protected becomes member of subclass of which type?

A. public member
B. private member
C. protected member
D. static member
Answer» C. protected member
1321.

Which of these keyword must be used to inherit a class?

A. super
B. this
C. extent
D. extends
Answer» E.
1322.

What is the output of this program? class A { public int i; protected int j; } class B extends A { int j; void display() { super.j = 3; System.out.println(i + " " + j); } } class Output { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); } }

A. 1 2
B. 2 1
C. 1 3
D. 3 1
Answer» B. 2 1
1323.

What is the output of this program? class A { int i; void display() { System.out.println(i); } } class B extends A { int j; void display() { System.out.println(j); } } class method_overriding { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); } }

A. 0
B. 1
C. 2
D. Compilation Error
Answer» D. Compilation Error
1324.

What is the output of this program? abstract class A { int i; abstract void display(); } class B extends A { int j; void display() { System.out.println(j); } } class Abstract_demo { public static void main(String args[]) { B obj = new B(); obj.j=2; obj.display(); } }

A. 0
B. 2
C. Runtime Error
D. Compilation Error
Answer» C. Runtime Error
1325.

What is the output of this program? class A { public int i; public int j; A() { i = 1; j = 2; } } class B extends A { int a; B() { super(); } } class super_use { public static void main(String args[]) { B obj = new B(); System.out.println(obj.i + " " + obj.j) } }

A. 1 2
B. 2 1
C. Runtime Error
D. Compilation Error
Answer» B. 2 1
1326.

What is the output of this program? class A { public int i; private int j; } class B extends A { void display() { super.j = super.i + 1; System.out.println(super.i + " " + super.j); } } class inheritance { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); } }

A. 2 2
B. 3 3
C. Runtime Error
D. Compilation Error
Answer» E.
1327.

Which of these packages contains abstract keyword?

A. java.lang
B. java.util
C. java.io
D. java.system
Answer» B. java.util
1328.

If a class inheriting an abstract class does not define all of its function then it will be known as?

A. Abstract
B. A Simple Class
C. Static class
D. None of the mentioned
Answer» B. A Simple Class
1329.

Which of these is not abstract?

A. Thread
B. AbstractList
C. List
D. None of the Mentioned
Answer» B. AbstractList
1330.

Which of these keywords are used to define an abstract class?

A. abst
B. abstract
C. Abstract
D. abstract class
Answer» C. Abstract
1331.

What is the output of this program? class A { int i; int j; A() { i = 1; j = 2; } } class Output { public static void main(String args[]) { A obj1 = new A(); System.out.print(obj1.toString()); } }

A. true
B. false
C. String associated with obj1
D. Compilation Error
Answer» D. Compilation Error
1332.

What is the output of this program? class Output { public static void main(String args[]) { Object obj = new Object(); System.out.print(obj.getclass()); } }

A. Object
B. Class Object
C. class java.lang.Object
D. Compilation Error
Answer» D. Compilation Error
1333.

What is the output of this program? class A { int i; int j; A() { i = 1; j = 2; } } class Output { public static void main(String args[]) { A obj1 = new A(); A obj2 = new A(); System.out.print(obj1.equals(obj2)); } }

A. false
B. true
C. 1
D. Compilation Error
Answer» B. true
1334.

What is the output of this program? abstract class A { int i; abstract void display(); } class B extends A { int j; void display() { System.out.println(j); } } class Abstract_demo { public static void main(String args[]) { B obj = new B(); obj.j=2; obj.display(); } }

A. 0
B. 2
C. Runtime Error
D. Compilation Error
Answer» C. Runtime Error
1335.

Which of these class relies upon its subclasses for complete implementation of its methods?

A. Object class
B. abstract class
C. ArrayList class
D. None of the mentioned
Answer» C. ArrayList class
1336.

Which of these keywords cannot be used for a class which has been declared final?

A. abstract
B. extends
C. abstract and extends
D. none of the mentioned
Answer» B. extends
1337.

Which of these keywords can be used to prevent inheritance of a class?

A. super
B. constant
C. class
D. final
Answer» E.
1338.

Which of these method of Object class is used to obtain class of an object at run time?

A. get()
B. void getclass()
C. Class getclass()
D. None of the mentioned
Answer» D. None of the mentioned
1339.

Which of these method of Object class can clone an object?

A. Objectcopy()
B. copy()
C. Object clone()
D. clone()
Answer» D. clone()
1340.

Which of these class is superclass of every class in Java?

A. String class
B. Object class
C. Abstract class
D. ArrayList class
Answer» C. Abstract class
1341.

What is the output of this program? class A { int i; public void display() { System.out.println(i); } } class B extends A { int j; public void display() { System.out.println(j); } } class Dynamic_dispatch { public static void main(String args[]) { B obj2 = new B(); obj2.i = 1; obj2.j = 2; A r; r = obj2; r.display(); } }

A. 1
B. 2
C. 3
D. 4
Answer» C. 3
1342.

What is the output of this program? class Abc { public static void main(String[]args) { String[] elements = { "for", "tea", "too" }; String first = (elements.length > 0) ? elements[0]: null; } }

A. Compilation error
B. An exception is thrown at run time
C. The variable first is set to null
D. The variable first is set to elements[0].
Answer» E.
1343.

What is the output of this program? final class A { int i; } class B extends A { int j; System.out.println(j + " " + i); } class inheritance { public static void main(String args[]) { B obj = new B(); obj.display(); } }

A. 2 2
B. 3 3
C. Runtime Error
D. Compilation Error
Answer» E.
1344.

What is the output of this program? class Alligator { public static void main(String[] args) { int []x[] = {{1,2}, {3,4,5}, {6,7,8,9}}; int [][]y = x; System.out.println(y[2][1]); } }

A. 2
B. 3
C. 7
D. Compilation Error
Answer» D. Compilation Error
1345.

Which of these is supported by method overriding in Java?

A. Abstraction
B. Encapsulation
C. Polymorphism
D. None of the mentioned
Answer» D. None of the mentioned
1346.

At line number 2 below, choose 3 valid data-type attributes/qualifiers among “final, static, native, public, private, abstract, protected” public interface Status { /* insert qualifier here */ int MY_VALUE = 10; }

A. final, native, private
B. final, static, protected
C. final, private, abstract
D. final, static, public
Answer» E.
1347.

Which of these is correct way of calling a constructor having no parameters, of superclass A by subclass B?

A. super(void);
B. superclass.();
C. super.A();
D. super();
Answer» E.
1348.

Which of these keywords can be used to prevent Method overriding?

A. static
B. constant
C. protected
D. final
Answer» E.
1349.

What is the process of defining a method in subclass having same name & type signature as a method in its superclass?

A. Method overloading
B. Method overriding
C. Method hiding
D. None of the mentioned
Answer» C. Method hiding
1350.

Which of these keyword can be used in subclass to call the constructor of superclass?

A. super
B. this
C. extent
D. extends
Answer» B. this