Java certification dumps | Java certification practice test


This is a Java practice test consisting of MCQs similar to the ones that are asked in the real certification exam. Also useful for the candidates aiming for the campus selection. This test covers broader java topics, while our other practice MCQs have specific java topics. Going through these tests will give the candidate a good indication of how well he is prepared for the real exam.



Java certification exam mock test

The test consists of 10 questions

No negative marking for this test.

No Time limit

The pass percentage is 70%

The correct answer with a description will be displayed after the answer has been marked.

Submit the test to calculate your score once you are done with all the questions.

Complexity Level- Moderate







Q1. What is wrong with the below java program?

class testClass{

public static void main(String[] args) {
int a;
System.out.println(a);
}
}














Q2: What are the errors in the below java program?
public class xyz {

int a ;
final int b;
int c =4;
final String str = "hello world";

public void func() {

int d;
String localstring = "hello everyone";
str=localstring;
System.out.println(str);
System.out.println(d);
System.out.println(a);

}

}

Select all that applies.


















Q3. What is wrong with the below java program?

final class test1{

protected static int a;
}

class test2 extends test1{

public static void main(String[] args) {

System.out.println(a);
}
}

















Q4: What default value will be acquired by variable 'a' in the below java program?

class testClass{

static int a;
public static void main(String[] args) {
System.out.println(a);
}
}

















Q5: Select the valid statements that can be inserted at position 1 of the below java program:

public class abc {

int a;
int b=0;
static int c;

public static void main(String[] args) {
int d;
int e=0;

//position 1
}
}




















Q6: What will be the output of executing the below java program:

class testClass{

public static void main(String[] args) {

int i=4;
float f = 4.3;
double d = 1.8;
int c =0;

if(i == f)
c++;
if(((int)(f+d)) == ((int) f) + (int)d)
c+= 2;

System.out.println(c);
}
}
















Q7: What is the execution result of the below java program?

interface inter{
void func();
}

class testClass implements inter{

public void func(){
System.out.println("hello world");
}

public static void main(String[] args) {
inter x = new inter();
x.func();
}
}

















Q8: Determine the output of the execution of the below java program

public class xyz {
int a;

xyz(){
a=9;
}

xyz(int i){
a=i;
}

public static void main(String[] args) {
xyz obj1 = new xyz();
xyz obj2 = new xyz(10);
obj1=obj2;
System.out.println(obj1.a);
}
}
















Q9: The below program will give a compilation error - Unhandled exception type Exception

public class xyz {
int a;
xyz() throws Exception{
a=9;
}

xyz(int i){
a=i;
}

public static void main(String[] args) {
xyz obj1 = new xyz();
xyz obj2 = new xyz(10);
obj1=obj2;
System.out.println(obj1.a);
}
}

Select the statements that will remove the compilation error from the above program


















Q10: Select the statements that can be inserted at position -1, so that the method 'func()' can be invoked without any compilation error:

interface inter{
void func();
}

class testClass implements inter{
public void func(){
System.out.println("hello world");
}

public static void main(String[] args) {
//position - 1
x.func();
}
}