Java Programming and Technical Programming Technical

Which three statements are true?

A. A method with the same signature as a private final method in class X can be implemented in a subclass of X.
B. A protected method in class X can be overridden by a subclass of A only if the subclass is in the same package as X.
C. A private static method can be called only within other static methods in class X.
D. A public static method in class X can be called by a subclass of X without explicitly referencing the class X.
E. A protected method in class X can be overridden by any subclass of X.
F. A final method in class X can be abstract if and only if X is abstract.
G. A non-static public final method in class X can be overridden in any subclass of X.

Read Solution (Total 0)

Java Other Question

A default method in an interface can be either private or public or protected. State True or False. What will be the output of the program?

class Tree { }

class Pine extends Tree { }

class Oak extends Tree { }

public class Forest1
{
public static void main (String [] args)
{
Tree tree = new Pine();

if( tree instanceof Pine )
System.out.println ("Pine");

else if( tree instanceof Tree )
System.out.println ("Tree");

else if( tree instanceof Oak )
System.out.println ( "Oak" );

else
System.out.println ("Oops ");
}
}

A. Oops
B. Tree
C. Pine
D. Forest