Java Programming and Technical Programming Output

What is the output of the following program?

class Icecream
{
public void displayName(String s)
{
System.out.println(s+" "+"Icecream");
}
public void describe(String s)
{
System.out.println(s+" "+"Icecream: Ice cream is a sweetened frozen food typically eaten as a snack or dessert. ");
}
}

class Faloodeh extends Icecream
{
public void displayName(String s)
{
System.out.println(s+" "+"Faloodeh ");
}

public void describe(String s)
{
System.out.println(s+" "+"Faloodeh: Faloodeh is often served alongside Persian-style dairy-based ice cream ");
}
}

public class Test
{
public static void main(String arg[])
{
Icecream a = new Faloodeh();
Faloodeh b = (Faloodeh)a;
a.displayName("test");
b.displayName("test");
a.describe("test");
b.describe("test");
}
}

A. test Faloodeh: Faloodeh is often served alongside Persian-style dairy-based ice cream
test Faloodeh: Faloodeh is often served alongside Persian-style dairy-based ice cream
test Faloodeh
test Faloodeh

B. test Faloodeh
test Faloodeh
test Faloodeh: Faloodeh is often served alongside Persian-style dairy-based ice cream
test Faloodeh: Faloodeh is often served alongside Persian-style dairy-based ice cream

C. test Faloodeh
test Faloodeh: Faloodeh is often served alongside Persian-style dairy-based ice cream
test Faloodeh: Faloodeh is often served alongside Persian-style dairy-based ice cream
test Faloodeh

D. test Faloodeh: Faloodeh is often served alongside Persian-style dairy-based ice cream
test Faloodeh
test Faloodeh
test Faloodeh: Faloodeh is often served alongside Persian-style dairy-based ice cream

Read Solution (Total 1)

Java Other Question

Which of the following statements are correct with respect to inheritance relationship in java?

A. object of subclass referenced by super class type can invoke super class methods
B. object of subclass referenced by super class type can access newly defined sub class variables
C. object of subclass referenced by super class type can access super class variables
D. object of subclass referenced by super class type can invoke overridden sub class methods
E. object of subclass referenced by super class type can invoke newly defined sub class methods
Given a method in a public class, ________ access modifier must be used to restrict access to that method to only the other members of the same class.

A. final
B. private
C. protected
D. default