100% found this document useful (4 votes)
205 views3 pages

Java Mock Tests For SCJP

Java mock tests for SCJP

Uploaded by

Thyagarajan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
205 views3 pages

Java Mock Tests For SCJP

Java mock tests for SCJP

Uploaded by

Thyagarajan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Sun Certified Java Programmer(SCJP 1.

4)
JavaBeat Home SCJP 1.4 Home Objectives Forums Mock Exams Online Mock Exam Resources

Mock Exams
MockQuestions - 1 MockQuestions - 2 MockQuestions - 3 MockQuestions - 4
MockQuestions - 5 MockQuestions - 6 MockQuestions - 7 MockQuestions - 8
MockQuestions - 9 MockQuestions - 10 MockQuestions - 11 MockQuestions - 12
MockQuestions - 13 MockQuestions - 14 MockQuestions - 15 MockQuestions - 16
MockQuestions - 17 MockQuestions - 18 MockQuestions - 19 MockQuestions - 20

Mock Exam - Arrays


Q1 Which of the following are valid array construction?
A1 int a[] = new int[];
A2 int a[] = new int[10];
A3 int a[10] = new int[];
A4 int a[] = new a[10];

Q2 Which of the following are valid array initialization?


A1 new int[] = {1,2,3,4};
A2 new int[10] = {1,2,3,4};
A3 new int[] = 1,2,3,4;
A4 new int[] = [1,2,3,4];

public class Test3{


public static void main(String args[]){
int arr[] = new int[10];
int i = 5;
Q3 arr[i++] = ++i+i++;
System.out.print(arr[5]+":"+arr[6]);
}
}
What will be the output?
A1 14:0
A2 0:14
A3 0:0
A4 Compiler Error

public class Test4{


public static void main(String args[]){
int arr[] = new int[10];
int i = 5;
Q4 arr[i++] = i+++i++;
System.out.print(arr[5]+":"+arr[6]);
}
}
What will be the output?
A1 13:0
A2 14:0
A3 0:14
A4 0:13

public class Test5{


static Boolean bl[] = new Boolean[5];
public static void main(String args[]){
Q5 System.out.println(bl[0]);
}
}
What will be the output?
A1 null
A2 false
A3 true
A4 Compiler Error

Q6 Which of the following are valid array declarations?


A1 String[][] a1 = String[20][20];
A2 String[][] a2 = new String[20,20];
A3 String[][] a3 = new String[20][20];
A4 String a4[][] = new String[20][20];
A5 String[] a5[] = new String[20][20];

Which of the following code correctly creates an array of


Q7
four initialized string objects?.
A1 String players[] = new String[4];
A2 String players[] = {"","","",""};
String players[];
A3
players = new String[4];
A4 None of the above.

char[] c = new char[100];

Q8 what is the value of c[50]?

A1 50
A2 49
A3 '\u0000'
A4 '\u0020'

Q9 which of the following are valid arrays?


A1 new float[10]={1,2};
A2 new float[]={1,2};
A3 new float={1,2};
A4 none of the above

public class Test10{


public void method(int arr[]){
arr[0] = 10;
}
public static void main(String[] args){
int[] small = {1,2,3};
Q10 Test10 t= new Test10();
t.method(small);
System.out.println(small[0]);
}
}
what will be the output?
A1 0
A2 1
A3 0
A4 none of the above
Answers
1 A2)int a[] = new int[10];
2 A1)new int[] = {1,2,3,4};
3 A1)14:0
4 A1)13:0
5 A1)null
A3 : String[][] a3 = new String[20][20];
6 A4 : String a4[][] = new String[20][20];
A5 : String[] a5[] = new String[20][20];
7 A2 : String players[] = {"","","",""};
8 c) '\u0000'
9 b)new float[]={1,2};
10 10

JavaBeat 2005, India (www.javabeat.net)


Submit a Site - Directory - Submit Articles

You might also like