Home Tutorial Java Scjp Part1 SCJP Module-1 Question-22

 
 

Share on Google+Share on Google+
SCJP Module-1 Question-22
Posted on: July 21, 2010 at 12:00 AM
Advertisement
The Sample program given below will test your understanding about the public final static variable in Java.

Given a sample code:

public class Test {
public static final String COOL = "boy";

public static void main(String[] args) {
Sub a = new Sub();
System.out.print(Test.COOL);
System.out.print(Sub.COOL);
System.out.print(a.COOL);
System.out.print(((Test) a).COOL);
}
}

class Sub extends Test {
public static final String COOL = "girl";
}

What will be the result? Choose the correct option?

(A) girl girl boy boy
(B) boy girl boy girl
(C) girl boy girl boy
(D) boy girl girl boy

Answer:

(B)

Advertisement

Related Tags for SCJP Module-1 Question-22:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 21, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com