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,185
  • Pages: 10
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 - 3

Q1

A1 A2 A3 A4

public class Test1{ public static void main(String args[]){ System.out.println(method()); } public static int method(){ try{ return 1; } catch(Exception e){ return 2; } finally{ return 3; } } } What will be the output? 1 2 3 0

public class Test2{ public static void main(String args[]){ System.out.println(method()); } public static int method(){ try{ throw new Exception(); return 1; } Q2 catch(Exception e){ return 2; } finally{ return 3; } } } What will be the output?

-

3 7 11 15 19

MockQuestions MockQuestions MockQuestions MockQuestions MockQuestions

-

4 8 12 16 20

A1 A2 A3 A4

Q3

A1 A2 A3 A4

Q4

A1 A2 A3 A4

1 2 3 4 Compiler error public class Test3{ public static void main(String args[]){ System.out.println(method()); } public static int method(){ try{ throw new Exception(); } catch(Exception e){ throw new Exception(); } finally{ return 3; } } } What will be the output? 3 0 Runtime Exception Compiler error public class Test4{ public static void main(String args[]){ System.out.println(method()); } public static int method(){ return; } } What will be the output? null 0 Runtime exception Compiler error

import java.io.IOException; public class Test5{ public static void main(String args[]){ try{ throw new IOException(); Q5 } catch(Exception e){ System.out.println("Excepion"); }

catch(IOException e){ System.out.println("IOExcepion"); } }

A1 A2 A3 A4

Q6

A1 A2 A3 A4

Q7

A1 A2 A3 A4

} What will be the output? Exception IOException Exception IOException Compilers error public class Test6{ public static void main(String args[]) throws Exception{ try{ throw new Exception(); } finally{ System.out.println("No Error"); } } } What will be the output? No Error followed by java.lang.Exception java.lang.Exception followed by No Error No Error Compiler Error ublic class Test7{ public static void main(String args[]) throws Exception{ Test7 t = new Test7(); t.method(); System.out.println("Print"); } public void method()throws Exception{ throw new Exception(); } } What will be the output? Print Exception thrown at runtime no output Compiler Error

public class Test8{ public static void main(String args[]) throws Exception{ Test8 t = new Test8(); t.method(); Q8 System.out.println("Print"); } public void method(){ try{

throw new Exception(); }catch(Exception e){} }

A1 A2 A3 A4

Q9

A1 A2 A3 A4

Q10

A1 A2 A3 A4

} What will be the output? Print Exception thrown at runtime no output Compiler Error public class Test9 extends A{ public static void main(String args[]) throws Exception{ Test9 t = new Test9(); } } class A{ A() throws Exception{ System.out.println("A Class"); } } What will be the output? A Class Runtimxception no output Compiler Error public class Test10 extends A{ Test10()throws Exception{ System.out.println("Test10 Class"); } public static void main(String args[]) throws Exception{ Test10 t = new Test10(); } } class A{ A() throws Exception{ System.out.println("A Class"); } } What will be the output? A Class Test10 Class Runtimxception no output Compiler Error public class Test11 extends A{ Test11()throws Exception{ System.out.println("Test10 Class"); } Test11(int i){} public static void main(String args[]) throws Exception{

Test11 t = new Test11(); } Q11

A1 A2 A3 A4

Q12

A1 A2 A3 A4

} class A{ A() throws Exception{ System.out.println("A Class"); } } What will be the output? A Class Test10 Class Runtimxception no output Compiler Error import java.io.IOException; public class Test12 extends A{ public void method() throws Exception{ System.out.println("Subclass"); } public static void main(String args[]) throws Exception{ A a = new A(); a.method(); a = new Test12(); a.method(); } } class A{ public void method() throws IOException{ System.out.println("Superclass"); } } What will be the output? Subclass Superclass Runtimxception Superclass Superclass Compiler Error

Q13 A1 A2 A3 A4

What are the legal arguments types for switch? int byte char All the above.

Q14 A1 A2 A3 A4

Which of the following are valif if constructs? if(2>3){} if(false){} if(false){} if(true)

Q15

A1 A2 A3 A4

Q16

A1 A2 A3 A4

public class Test15{ public static void main(String args[]) throws Exception{ for (int i = 0;i < 3;i++){ for (int j = 0;j < 3;j++){ System.out.print(i); System.out.print(j+","); break; } } } } What will be the output? 00, 00,10,20, 000102 None of the above public class Test16 extends A{ Test16(){ System.out.println("Sub"); } public static void main(String args[]) { Test16 t = new test16(); } } class A{ A(int i){ System.out.println("Super"); } } What will be the output? Super Sub Super Sub Compiler Error

public class Test17 extends A{ Test17(int i){ System.out.println(i); super(2); } public static void main(String args[]) { Test17 t = new Test17(5); } Q17 } class A{ A(int i){ System.out.println(i); } } What will be the output? A1 5 2

A2 2 5 A3 5 5 A4 Compiler error

Q18

A1 A2 A3 A4

public class Test18 { Test18(){ this(7); } Test18(int i){ this(1.0); Test18(i); } Test18(float f){ System.out.println(f * 2); } Test18(double d){ System.out.println(d * 3); } void Test18(int i){ System.out.println(i); } public static void main(String args[]) { Test18 t = new Test18(); } } What will be the output? 3.0 7 2.0 7 7 3.0 Compiler Error

public class Test19 { float f; Test19(){ this(f); f = 3; } Test19(float f){ Q19 System.out.println(f); } public static void main(String args[]) { Test19 t = new Test19(); } } What will be the output? A1 A2 A3 A4

0.0 0 3 Compiler error public class Test20 extends A{

Q20

Test20(){ this("Hi"); } Test20(String str){ System.out.println(str); } public static void main(String args[]) { Test20 t = new Test20(); } } class A{ A(){ System.out.println("Super"); } } What will be the output?

A1 A2 A3 A4

Q21

A1 A2 A3 A4

Q22

A1 A2 A3 A4

Super Hi Hi Super Super Compiler Error public class Test21{ public static void main(String args[]) { Test21 t; t.method(); } public static void method(){ System.out.println("NullPointerException"); } } What will be the output? Nothing is printed. RuntimeException NullPointerException Compiler Error public class Test22{ public static void main(String args[]) { Test22 t = null; t.method(); } public static void method(){ System.out.println("NullPointerException"); } } What will be the output? Nothing is printed. RuntimeException NullPointerException Compiler Error

Q23 A1 A2 A3 A4

Which of the following modifiers are allowed in constructor? private default public static

Q24 A1 A2 A3 A4

Which of the following modifiers are allowed for top-level classes? private static public strictfp

Q25 A1 A2 A3 A4

which one of the keyword cannot be used with instance variables? transient volatile synchronized abstract Answers

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

3 Compiler Error Compiler Error Compiler Error Compiler Error No Error followed by java.lang.Exception Exception thrown at runtime Print Compiler Error A Class Test10 Class Compiler Error Compiler Error All the above if(2>3){} if(false){} if(true){} 00,10,20, Compiler Error Compiler Error 3.0 7 Compiler Error Super Hi Compiler Error NullPointerException

private public strictfp 24 public synchronized 25 abstrct

23

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