Practice More Quizzes:
Q:
What is the output of the code below? abstract class Beverage { abstract void pour(); } class Tea extends Beverage { @Override void pour() { System.out.println(“Pouring Tea”); } } class Coffee extends Beverage { @Override void pour() { System.out.println(“Pouring Coffee”); } } class Test { public static void main(String[] args) { Beverage tea = new Coffee(); tea.pour(); } }
Q:
What is the output of the code below if we change the first line in the main function to be: Beverage bev = new Beverage(); abstract class Beverage { abstract void pour(); } class Tea extends Beverage { @Override void pour() { System.out.println(“Pouring Tea”); } } class Coffee extends Beverage { @Override void pour(){ System.out.println(“Pouring Coffee”); } } class Test { public static void main(String[] args) { Beverage tea = new Coffee(); tea.pour(); } }
Q:
What is the output of the code below? class Test { public static void main(String[] args) { Teacher yourTA = new TeachingAssistant(); yourTA.grade(); yourTA.officeHour(); } } abstract class Teacher { public Teacher() { System.out.println(“New Teacher created”); } abstract void grade(); void officeHour() { System.out.println(“Office Hours”); } } class TeachingAssistant extends Teacher { @Override void grade() { System.out.println(“Grade your hw7 now”); } }
Q:
What’s the result of the following code? abstract class Base { void fun() { System.out.println(“Base fun() called”); } } class Derived extends Base {} class Main { public static void main(String args[]) { Base b = new Derived(); b.fun(); } }
Q:
What’s the result of the following code? abstract class Base { void fun() { System.out.println(“Base fun() called”); } } class Derived extends Base { @Override void fun() { System.out.println(“Fun overwritten!”); } } class Main { public static void main(String args[]) { Base b = new Derived(); b.fun(); } }
Q:
How can we stop execution of a program, and move from one desired step to another?
Q:
Which of the following allows us to deep dive into the execution of a method call, from within another method?
Q:
When using Eclipse’s debugger, which button will you click if you want to go back to the caller of the current method?
Subscribe
0 Comments
Find Questions in This Page: "CTRL+F"