400 Mock Questions on SCJP 1.6 - JUST Rs.300 or 10 USD
Send us mail to sales@javabeat.netmore details
Do you have paypal account? Click Here to pay now and get the questions.
Mock Exam - 3
Q1
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?
A1
1
A2
2
A3
3
A4
0
Q2
public class Test2{
public static void main(String args[]){
System.out.println(method());
}
public static int method(){
try{
throw new
Exception();
return 1;
}
catch(Exception e){
return 2;
}
finally{
return 3;
}
}
}
What will be the output?
1
A1
2
A2
3
A3
4
A4
Compiler error
Q3
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?
A1
3
A2
0
A3
Runtime Exception
A4
Compiler error
Q4
public class Test4{
public static void main(String args[]){
System.out.println(method());
}
public static int method(){
return;
}
}
What will be the output?
A1
null
A2
0
A3
Runtime exception
A4
Compiler error
Q5
import java.io.IOException;
public class Test5{
public static void main(String args[]){
try{
throw new
IOException();
}
catch(Exception e){
System.out.println("Excepion");
}
catch(IOException e){
System.out.println("IOExcepion");
}
}
}
What will be the output?
A1
Exception
A2
IOException
A3
Exception IOException
A4
Compilers error
Q6
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?
A1
No Error followed by java.lang.Exception
A2
java.lang.Exception followed by No Error
A3
No Error
A4
Compiler Error
Q7
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?
A1
Print
A2
Exception thrown at runtime
A3
no output
A4
Compiler Error
Q8
public class Test8{
public static void main(String args[])
throws Exception{
Test8 t = new
Test8();
t.method();
System.out.println("Print");
}
public void method(){
try{
throw new Exception();
}catch(Exception e){}
}
}
What will be the output?
A1
Print
A2
Exception thrown at runtime
A3
no output
A4
Compiler Error
Q9
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?
A1
A Class
A2
Runtimxception
A3
no output
A4
Compiler Error
Q10
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?
A1
A Class Test10 Class
A2
Runtimxception
A3
no output
A4
Compiler Error
Q11
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();
}
}
class A{
A() throws Exception{
System.out.println("A Class");
}
}
What will be the output?
A1
A Class Test10 Class
A2
Runtimxception
A3
no output
A4
Compiler Error
Q12
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?
A1
Subclass Superclass
A2
Runtimxception
A3
Superclass Superclass
A4
Compiler Error
Q13
What are the legal arguments types for switch?
A1
int
A2
byte
A3
char
A4
All the above.
Q14
Which of the following are valif if
constructs?
A1
if(2>3){}
A2
if(false){}
A3
if(false){}
A4
if(true)
Q15
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?
A1
00,
A2
00,10,20,
A3
000102
A4
None of the above
Q16
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?
A1
Super Sub
A2
Super
A3
Sub
A4
Compiler Error
Q17
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);
}
}
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
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?
A1
3.0 7
A2
2.0 7
A3
7 3.0
A4
Compiler Error
Q19
public class
Test19 {
float f;
Test19(){
this(f);
f = 3;
}
Test19(float f){
System.out.println(f);
}
public static
void main(String args[]) {
Test19 t = new Test19();
}
}
What will be the output?
A1
0.0
A2
0
A3
3
A4
Compiler error
Q20
public class
Test20 extends A{
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
Super Hi
A2
Hi Super
A3
Super
A4
Compiler Error
Q21
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?
A1
Nothing is printed.
A2
RuntimeException
A3
NullPointerException
A4
Compiler Error
Q22
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?
A1
Nothing is printed.
A2
RuntimeException
A3
NullPointerException
A4
Compiler Error
Q23
Which of the following
modifiers are allowed in
constructor?
A1
private
A2
default
A3
public
A4
static
Q24
Which of the following
modifiers are allowed for
top-level classes?
A1
private
A2
static
A3
public
A4
strictfp
Q25
which one of the keyword
cannot be used with
instance variables?
A1
transient
A2
volatile
A3
synchronized
A4
abstract
Answers
1
3
2
Compiler Error
3
Compiler Error
4
Compiler Error
5
Compiler Error
6
No Error followed by
java.lang.Exception
7
Exception thrown at
runtime
8
Print
9
Compiler Error
10
A Class Test10 Class
11
Compiler Error
12
Compiler Error
13
All the above
14
if(2>3){}
if(false){}
if(true){}
15
00,10,20,
16
Compiler Error
17
Compiler Error
18
3.0 7
19
Compiler Error
20
Super Hi
21
Compiler Error
22
NullPointerException
23
private
public
24
strictfp
public
25
synchronized
abstrct
400 Mock Questions on SCJP 1.6 - JUST Rs.300 or 10 USD
Send us mail to sales@javabeat.netmore details