Java Mock Tests For Scjp

  • Uploaded by: Thyagarajan
  • 0
  • 0
  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Java Mock Tests For Scjp as PDF for free.

More details

  • Words: 1,164
  • Pages: 8
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

Mock Exam - 1

Q1

A1 A2 A3 A4 Q2 A1 A2 A3 A4

Q3

A1 A2 A3 A4

public class Test1{ public static void main(String[] args){ int arr[] = new int[3]; for(int i = 0;i < arr.length;i++){ System.out.println(arr[i]); } } } What will be the output? 000 ArrayIndexoutOfBoundsException NullPointerException null null null Which of the following are valid array declarations? int arr[] = new int[]; float arr[10] = new fl double []arr = new double[10]; None Of the Above. public class Test3{ public void method(){ System.out.println("Called"); } public static void main(String[] args){ method(); } } What will be the output? "Called" Compiler Runtime Nothing

public class Test4{ public static void method(){ Q4 System.out.println("Called"); } public static void main(String[] args){

-

3 7 11 15 19

MockQuestions MockQuestions MockQuestions MockQuestions MockQuestions

-

4 8 12 16 20

Test4 t4 = null; t4.method(); }

A1 A2 A3 A4

Q5

A1 A2 A3 A4

Q6

A1 A2 A3 A4

} What will be the output? "Called" Compiler Runtime Exception Nothing is printed in screen public class Test5{ public void Test5(){ System.out.println("Constructor1"); } public Test5(){ System.out.println("Constructor2"); } public static void main(String[] args){ Test5 t5 = new Test5(); } } What will be the output? "Constructor1" "Constructor2" "Constructor1""Constructor2" Compiler Errror public class Test6{ public Test6(){ this(4); } public Test6(byte var){ System.out.println(var); } public static void main(String[] args){ Test6 t6 = new Test6(); } } What will be the output? 4 44 Compiler Error Compiles and Runs without error public class Test7{ public Test7(){} public Test7(Test7 ref){ this (ref,"Hai"); } public Test7(Test7 ref,String str){ ref.Test7(str);

System.out.println("Hi"); } public void Test7(String str){ System.out.println(str); } public static void main(String[] args){ Test7 t = new Test7(); Test7 t7 = new Test7(t); }

Q7

}

A1 A2 A3 A4 Q8 A1 A2 A3 A4

What will be the output? HI hai Hai Hi Hi Hai Which of the following are valid Constructors? public Test8(){} private void Test8(){} protected Test8(int k){} Test8(){}

Q9 Which of the following are valid method declarations? A1 abstract method(){} A2 abstrct void method(){} A3 final void method(){} A4 int method(){} Q10 A1 A2 A3 A4

Which of the following are valid top-level class declarations? class Test10 public class Test10 final class Test10 abstract final class Test10

Q11 A1 A2 A3 A4

transient keywaord can be used with? method variable class constructor

Q12 A1 A2 A3 A4

which of the following are valid combinations for class declaration? abstract final class Test12{} abstract static class Test12{} final static class Test12{} public final strictfp class Test12{}

Q13 which of the following are valid constructor signatures? public void className() A1

A2

A3

A4

Q14 A1 A2 A3 A4 A5

Q15

A1

public void className()

private className()

static className()

Which of the following modifiers can be used with top class declaration?

static privatr public final abstract Which of the following are valid array declarations?

int arr[] = new int[];

A2 int arr[][] = new int [10][10]; A3 float arr[][] = new float[][10]; A4 float arr[] = new float[10]; What will be the output of the following program? public class Test1 { static{ System.out.println("Static"); } { System.out.println("Instance"); } Q16 public void Test1(){ System.out.println("Constructor"); } public static void main(String[] args) { Test1 t = null; } }

A1 A2 A3 A4

Instance Static Static Instance Static Static Instance Constructor What will be the output of the following program? class Sup{ public Sup(String str){ System.out.println("Super class"); } }

Q17 public class Test2 extends Sup{ public Test2(){ System.out.println("Sub class"); } public static void main(String[] args) { Test2 t2 = new Test2(); } } A1 A2 A3 A4

Super class,SubClass Super class Sub class Compiler Error

What will be the output of the following program? public class Test3 { public static void main(String[] args) { System.out.println("Main Method1"); } Q18 public static void main(String args){ System.out.println("Main Method2"); } } A1 A2 A3 A4

Main Method1 Main Method1 Main Method2 Main Method2 Runtime Exception What will be the output of the following program?

public class Test4 { public static void main(String args) { Q19 System.out.println("Sample Program"); } } A1 A2 A3 A4

Sample Program Compiler Error Runtime Exception None

What will be the output of the following program? class Sup1{ public Sup1(){ System.out.println("Hai"); } private Sup1(String str){ System.out.println(str); } } Q20 public class Test5 extends Sup1{ private Test5(String str){ System.out.println(str); super(); } public static void main(String[] args) { Test5 t5 = new Test5("HI"); } } A1 A2 A3 A4

Hai,Hi,Hi Hai,Hi Hi,Hi Compiler Error

Q21 Which of the following are not a wrapper class? String A1 ing A2 Integer StringBuffer A3 A4 Boolean Q22 A1 A2 A3 A4

Select the correct syntax for main method : public void main(String args[]) public static void main(String args) public static void Main(String args[]) None of the Above

Q23 A1 A2 A3 A4

Which of the following are not a valid declarations? float f = 1; float f = 1.2f; float f = 1.2; float f = (float)1.2;

String s1 = new String("hi"); String s2 = "hi"; Q24 System.out.println(s1 ==s2); System.out.println(s1.equals(s2)); A1 A2 A3 A4

false true true false true true None of the above.

Integer i = new Integer(0); Float f = new Float(0); System.out.println(i==f); Q25 System.out.println(i.equals(f));

A1 A2 A3 A4

true false false true true true Compiler error Answers

1

A1 is correct Local Array variables are initialized to their default values.

2

A3)double []arr = new double[10]; A1 is not valid because (new int[]) array size must be specified unless it is annonymous array declaration. A2 is not valid because array declaration must not specify the size of the array.

3

A2) Compiler Error non-static(instance) methods or variables are cannot be referenced from static context.Compiler will give the following error while compiling the above code: Test3.java:6: non-static method method() cannot be referenced from a static context method();

4

A1) "Called" Static methods canbe called only by referance.Because its not binded with objects.So, in this case "null" value doesn't make sense."method" is called without any problem.

5

A2)"Constructor2" Constructors cannot have return types. If its declared with return types then it is consider as methods. So, output wull be "Constructor2".

6

A3)Compiler Error

7

A3)Hai Hi

8

A1)public Test8(){} A3)protected Test8(int k){}

9

A3)final void method(){} A4)int method(){}

A1) class Test10 10 A2) public Test10 A3) final Test10 11 b)variable

12

13

c)final static class() d)public final strictfp class{}

b)public className() c)private className()

c)public 14 d)final e)abstract 15

b)int arr[][] = new int [10][10]; d)float arr[] = new float[10];

16 c)Static 17 d)Compiler Error 18 a)Main Method1 19 c)Runtime Exception 20 d)Compiler Error

21

A1)String A4)String Buffer

22 A4)None of the Above 23 A3)float f = 1.2; 24 A1) false true 25 A4)Compiler error JavaBeat 2005, India (www.javabeat.net) Submit a Site - Directory - Submit Articles

Related Documents

Java Mock Tests For Scjp
October 2019 11
Java Mock Tests For Scjp
October 2019 13
Java Mock Tests For Scjp
October 2019 11
Java Mock Tests For Scjp
October 2019 16
Java Mock Tests For Scjp
October 2019 13
Java Mock Tests For Scjp
October 2019 19

More Documents from "Thyagarajan"

Java Mockexam - 6
October 2019 16
Java Mock Tests For Scjp
October 2019 19
Java Mock Tests For Scjp
October 2019 23
Java Mockexam - 20
October 2019 21
Java Mock Tests For Scjp
October 2019 13