- SELENIUM
- JMeter
- DevOps
- VERSION CTRL
- Online Test
- Number System MCQ - 1
- Number System MCQ - 2
- Number System MCQ - 3
- Simplification MCQ
- Average MCQ
- Simple Interest MCQ
- Compound Interest MCQ
- Percentage MCQ
- Ratio and Proportion MCQ
- Selenium MCQ-1
- Selenium MCQ-2
- Selenium MCQ-3
- Mock ISTQB
- Mock CSM
- Software Testing MCQ
- Java MCQ -1
- Java MCQ -2
- Java MCQ -3
- Java MCQ -4
- Java MCQ -5
- Java MCQ -6
- Java MCQ -7
- S/W PROJECT MANAGEMENT
- PROTRACTOR
- Java -Tutorials
- MORE
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);
}
}
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.
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);
}
}
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);
}
}
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
}
}
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);
}
}
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();
}
}
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);
}
}
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
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();
}
}
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();
}
}