Sun Certified Java Programmer(SCJP 1.

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

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

Mock Exam - Arrays Q1 A1 A2 A3 A4 Q2 A1 A2 A3 A4 Which of the following are valid array construction? int a[] = new int[]; int a[] = new int[10]; int a[10] = new int[]; int a[] = new a[10]; Which of the following are valid array initialization? new int[] = {1,2,3,4}; new int[10] = {1,2,3,4}; new int[] = 1,2,3,4; new int[] = [1,2,3,4];

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

Q4

A1 A2 A3

A4 0:13 public class Test5{ static Boolean bl[] = new Boolean[5]; public static void main(String args[]){ System.out.println(bl[0]); } } What will be the output? null false true Compiler Error Which of the following are valid array declarations? String[][] a1 = String[20][20]; String[][] a2 = new String[20,20]; String[][] a3 = new String[20][20]; String a4[][] = new String[20][20]; String[] a5[] = new String[20][20];

Q5

A1 A2 A3 A4 Q6 A1 A2 A3 A4 A5 Q7

Which of the following code correctly creates an array of 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 A2 A3 A4

50 49 '\u0000' '\u0020'

Q9

which of the following are valid arrays?

A1 A2 A3 A4

new float[10]={1,2}; new float[]={1,2}; new float={1,2}; 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}; Test10 t= new Test10(); t.method(small); System.out.println(small[0]); } } what will be the output? 0 1 0 none of the above Answers

Q10

A1 A2 A3 A4 1 2 3 4 5

A2)int a[] = new int[10]; A1)new int[] = {1,2,3,4}; A1)14:0 A1)13:0 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

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.