Welcome Guest | Sign in | Register
Declarations and Access Control - Discussion Page For Q.2590 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Exercise:

Section 1

Q: What will be the output of the program?
import java.util.*;
public class NewTreeSet2 extends NewTreeSet{
public static void main(String [] args){
NewTreeSet2 t = new NewTreeSet2();
t.count();
}
}
protected class NewTreeSet{
void count(){
for (int x = 0; x < 7; x++,x++ ){
System.out.print(" " + x);
}
}
}
A. 0 2 4 6 B. 0 2 4
C. Compilation fails at line 10 D. Compilation fails at line 2

Answer and Explanation

Answer:Compilation fails at line 10

Explanation:
Non-nested classes cannot be marked protected (or final for that matter), so the compiler will fail at protected class NewTreeSet.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.