Java mcq and Test

JAVA MCQ and Test
Instruction:
1.This is a FREE online test. 
2.Total number of questions : 20.
3.DO NOT refresh the page.
4.You will get your online test score after finishing the complete test.
there is no time limit. 
All the best :👍


Click start Quiz:


1What should be the execution order, if a class has a method, static block, instance block, and
constructor, as shown below?
public class First_C {
public void myMethod()
{
System.out.println("Method");
}
{
System.out.println(" Instance Block");
}
public void First_C()
{
System.out.println("Constructor ");
}
static {
System.out.println("static block");
}
public static void main(String[] args) {
First_C c = new First_C();
c.First_C();
c.myMethod();
}
}
a.Instance block, method, static block, and constructor
b.Method, constructor, instance block, and static blo
c.Static block, method, instance block, and constructor
d.Static block, instance block, constructor, and method

2._____ is used to find and fix bugs in the Java programs.
a.JVM
b.JRE
c .JDK
d.JDB.

3.Which of the following is a valid declaration of a char?
a.char ch = '\utea';
b.char ca = 'tea';
c.char cr = \u0223;
d.char cc = '\itea';

4.Evaluate the following Java expression, if x=3, y=5, and z=10:
++z + y - y + z + x++
a.24
b.23
c.20
d.25

5.In which process, a local variable has the same name as one of the instance variables?
a.Serialization
b.Variable Shadowing
c.Abstraction
d.Multi-threading

6 .Which package contains the Random class?
a.java.util package
b.java.lang package
c.java.awt package
d.java.io package

7.In which memory a String is stored, when we create a string using new operator?
a.Stack
b.String memory
c.Heap memory
d.Random storage space

8.Which of the following is a mutable class in java?
a.java.lang.String
b.java.lang.Byte
c.java.lang.Short
d.java.lang.StringBuilder

9.The while loop repeats a set of code while the condition is not met?
a) True
b) False

10.Which of the following is not a valid jump statement?
a) break
b) goto
c) continue
d) return

11.Which of the following creates a List of 3 visible items and multiple selections abled?
a.new List(false, 3)
b.new List(3, true)
c.new List(true, 3)
d.new List(3, false)

12.Which of the following for loop declaration is not valid?
a.for ( int i = 99; i >= 0; i / 9 )
b.for ( int i = 7; i <= 77; i += 7 )
c.for ( int i = 20; i >= 2; - -i )
d.for ( int i = 2; i <= 20; i = 2* i )

13.Which of the following modifiers can be used for a variable so that it can be accessed by any
thread or a part of a program?
a.global
b.transient
c.volatile
d.default

14.What concepts come under Polymorphism in java?
a.Method overloading
b.Constructor overloading
c.Method overriding
d.All the above

15.Which inheritance in java programming is not supported
a.Multiple inheritance using classes
b.Multiple inheritance using interfaces
c.Multilevel inheritance
d.Single inheritance

16.Which class cannot be sub classed?
a.final class
b.object class
c.abstract class
d.child class

17.Which method is called internally by Thread start() method?
a.execute()
b.run()
c.launch()
d.main()

18.
public class Outer
{
public void someOuterMethod()
{
//Line 5
}
public class Inner { }
public static void main(String[] argv)
{
Outer ot = new Outer();
//Line 10
}
}
Which of the following code fragments inserted, will allow to compile?
a.new Inner(); //At line 5
b.new Inner(); //At line 10
c.new ot.Inner(); //At line 10
d.new Outer.Inner(); //At line 10

19.Which of the following class level (nonlocal) variable declarations will not compile?
a.protected int a;
b.transient int b = 3;
c.private synchronized int e;
d.volatile int d;

20.Which of the following tool is used to generate API documentation in HTML format from doc
comments in source code?
a.javap tool
b.javaw command
c.Javadoc tool
d.javah command
DOWNLOAD MCQ PDF:📩
Answer:
1.c
2.d
3.a
4.a
5.b
6.a
7.c
8.d
9.b
10.b
11.b
12.a
13.c
14.d
15.a
16.a
17.b
18.a
19.c
20.c
Post a Comment (0)
Previous Post Next Post