JavaQuizzes

Quiz Guidelines

 

Multiple Choice Question

QID: 
27

What will the program print?

class Parent{
	
	public void myMethod()
	{
		System.out.println("Parent myMethod");
	}
}

class Child extends Parent{
	
	public void myMethod()
	{
		System.out.println("Child myMethod");
	}
}

class OverridingCheck {

	public static void main(String args[])
	{
		Parent p = new Child();
		p.myMethod();
	}

}

 

Select 1 option

A. Prints "Parent myMethod"

B. Prints "Child myMethod"

C. Compilation Fails

D. Exception at Runtime

Multiple Choice Question

QID: 
28

What will the program print?

class Parent{
	
	public static void myMethod()
	{
		System.out.println("Parent myMethod");
	}
}

class Child extends Parent{
	
	public static void myMethod()
	{
		System.out.println("Child myMethod");
	}
}

class OverridingCheck {

	public static void main(String args[])
	{
		Parent p = new Child();
		p.myMethod();
	}

}

 

Select 1 option

A. Prints "Parent myMethod"

B. Prints "Child myMethod"

C. Compilation Fails

D. Exception at Runtime

Multiple Choice Question

QID: 
29

What will the program print?

class Parent{
	
	public static void myMethod()
	{
		System.out.println("Parent myMethod");
	}
}

class Child extends Parent{
	
	public void myMethod()
	{
		System.out.println("Child myMethod");
	}
}

class OverridingCheck {

	public static void main(String args[])
	{
		Parent p = new Child();
		p.myMethod();
	}

}

 

Select 1 option

A. Prints "Parent myMethod"

B. Prints "Child myMethod"

C. Compilation Fails

D. Exception at Runtime

Multiple Choice Question

QID: 
30

What will the program print?

class Parent{
	
	public void myMethod()
	{
		System.out.println("Parent myMethod");
	}
}

class Child extends Parent{
	
	public static void myMethod()
	{
		System.out.println("Child myMethod");
	}
}

class OverridingCheck {

	public static void main(String args[])
	{
		Parent p = new Child();
		p.myMethod();
	}

}

 

Select 1 option

A. Prints "Parent myMethod"

B. Prints "Child myMethod"

C. Compilation Fails

D. Exception at Runtime

Multiple Choice Question

QID: 
31

Given:

public class ExceptionCheck {
	
	static int i = 10;
	
	public static void main (String[] argds)
	{
		System.out.println(myMethod());
		System.out.println(i);
	}
	
	public static int myMethod()
	{
		try{
			throw new Exception();
		}
		catch(Exception e)
		{
			return i;
		}
		finally{
			i = 12;
		}
	}
}

 

Select 1 option

A. Compilation Fail

B. Print 10 and 12.

C. Print 10 and 10.

D. Print 12 and 12.

Pages

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!