Java MockExam - 1
Java MockExam - 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 - 1
public class Test1{
public static void main(String[] args){
int arr[] = new int[3];
for(int i = 0;i < arr.length;i++){
Q1 System.out.println(arr[i]);
}
}
}
What will be the output?
A1 000
A2 ArrayIndexoutOfBoundsException
A3 NullPointerException
A4 null null null
Q12 which of the following are valid combinations for class declaration?
A1 abstract final class Test12{}
A2 abstract static class Test12{}
A3 final static class Test12{}
A4 public final strictfp class Test12{}
Q13 which of the following are valid constructor signatures?
public void className()
A1
private className()
A3
static className()
A4
Which of the following modifiers can be used with top class declaration?
Q14
A1 static
A2 privatr
A3 public
A4 final
A5 abstract
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 Hai,Hi,Hi
A2 Hai,Hi
A3 Hi,Hi
A4 Compiler Error
A4 Boolean
A1 true false
A2 false true
A3 true true
A4 Compiler error
Answers
A1 is correct
1
Local Array variables are initialized to their default values.
A1) "Called"
4 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.
A2)"Constructor2"
5 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
A1)public Test8(){}
8
A3)protected Test8(int k){}
A3)final void method(){}
9
A4)int method(){}
11 b)variable
b)public className()
13
c)private className()
c)public
14 d)final
e)abstract
16 c)Static
17 d)Compiler Error
18 a)Main Method1
19 c)Runtime Exception
20 d)Compiler Error
A1)String
A4)String Buffer
21
23 A3)float f = 1.2;
25 A4)Compiler error
JavaBeat 2005, India (www.javabeat.net)
Submit a Site - Directory - Submit Articles