About  | Contact  | Site Map  |  Mirror   
Voodoo Exam  |  Question Bank  |  Databases  |  Tutorials   

In this Section
Question Bank 1
Question Bank 2
Question Bank 3
Objective 2



Previous Section
Back to Java
Voodoo Exam
Question Banks
Tutorials
Applets


Main Links
Home
Java
Tabs
Downloads
About Myself


   

Question Bank 2

We have moved to a new website(www.irixtech.com) where you can now take mock exams online, come back & review your answers later, ask questions in our forums & SCJP questions ranging from SCJP 1.4 to SCJP 6.0, including these question banks & dumps from this site.

Click here to take this question bank as an interactive mock exam


Comments & suggestions will be highly appreciated . If you'd like to see your question's here mail me .


1. What is the output when Test01 class is run ?

class A{

	A(){
		//some initialization
	}

	void do_something(){
		System.out.println("I'm in A");
	}
};

class B extends A{

	B(){
		//some initialization
	}

	void do_something(){
		System.out.println("I'm in B");
	}
};

class Test01{

	public static void main(String args[]){
		A a = new B();
		a.do_something();
	}
};

Options :

  1. I'm in A
  2. I'm in B
  3. Compiler error , A a = new B ( ) : Explicit cast needed to convert A to B
  4. ClassCastException thrown at runtime

2. What is the output for the following code ?

class Q014{
	
	public String get(int i){
		return null;
	}
	
	public static void main(String ka[]){
		System.out.println((new Q014()).get(1));
	}
};

Options :

  1. 0
  2. NullPointerException at run-time
  3. Compile error
  4. null

3.What is the output ?

class Q018{
	static Object obj;
	static String get(){
		return null;
	}

	public static void main(String args[]){
		System.out.println((Q018.get()) == (Q018.obj));
	}
};

Options :

  1. Compile error
  2. Run-time error
  3. true
  4. false

4. What is the output ?

class Q015{
	
	public String get(int i){
		return null;
	}
	
	public static void main(String ka[]){
		Q015 obj = new Q015();
		Object i = obj.get(10);
		System.out.println(i.toString());
	}
};

Options :

  1. null
  2. NullPointerException at run-time
  3. Compile error
  4. 0

5.What is the output ?

class Q013{
	int i;

	Q013(int i){
		System.out.println(i);

	}

	public static void main(String ka[]){
		Q013 obj = new Q013(10);
		System.out.println(obj.i);
	}

}

Options :

  1. 10
    10
  2. Compile error , System.out.println ( obj.i ) : variable i may not have been initialized
  3. 0
    10
  4. 10
    0

6. What is the output ?

class Test02{

	public String fetch(){
		return null;
	}

	public static void main(String args[]){
		Test02 obj = new Test02();
		String str = obj.fetch();
		System.out.println((str+"").toString());
	}
};

Options :

  1. null
  2. Compiler error , can't invoke a method on null
  3. NullPointerException thrown at runtime
  4. ClassCastException thrown at runtime

7. What is the output ?

class Q022{
	public static void main(String ka[]){
		while(false){
			System.out.println("Great");
		}
	}
};

Options :

  1. Run's with no output
  2. Run-time error " Statement not reached."
  3. Great
  4. Compiler error , System.out.println ( "Great") : statement not reached

8. What is the output ?

class A{
	static int i;	

	private int get(){
		return 1;
	}
};

class B extends A{

	private int get(){
		return 2;
	}
};

class Q027 extends B{

	public static void main(String ka[]){
		Q027 obj = new Q027();
		System.out.println(obj.get());
	}
};

Options :

  1. 2
  2. Compile error , System.out.println ( obj.get ( ) ) : no method matching get ( ) found in class Q027
  3. 1
  4. 2
  5. NullPointerException thrown at run-time .

9. What is the output ?

class Q029{
	public static void main(String args[]){
		boolean b[] = new boolean[2];
		System.out.println(b[1]);
	}
};

Options :

  1. Compile error " Variable b may not have been initialized."
  2. Run-time error " Variable b may not have been initialized."
  3. false
  4. true

10. Consider the following applet . Is there something wrong with it ? Choose the most appropriate option ( only one ) .

public class App_Test extends Applet{

	App_Test(){
		//some initialization
	}

	public void paint(Graphics g){
		g.drawString("Applet started" , 50 , 50);
	}
};

Options :

  1. Nothings wrong with it
  2. It should override the init ( ) method of it's superclass ( Applet )
  3. An applet subclass can't override the default constructor
  4. The drawString ( ) method in paint ( ) has wrong number of arguments
  5. The constructor of App_Test must be defined as public

Answers :

  1. b
  2. d
  3. c
  4. b
  5. d
  6. a
  7. d
  8. b
  9. c
  10. e

End of Page

Disclaimer  |  Contact  |  Mirror  |  Downloads
© 2000-2002 Ashish Hareet