on 09-27-2006 12:38 PM
hello ! i m a beginner in java. Kindly help me to solve this question.
wat'll happen when u attempt to compile and run thid code
public class Hope{
public static void main(String argv[]){
Hope h=new Hope();
}
protected Hope(){
for(int i=0;i<10;i++){
System.out.println(i);
}
}
}
Options
1. Compilation error : Constructors cannot be declared protected
2.Run time error: Constructors cannot be declared protected
3.Compilation and running with output 0 to 10
4.Compilation and running with output 0 to 9
Hi Payal,
Options: 4 is the output.
See this link also: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/Constructor.html
http://javaalmanac.com/egs/java.lang.reflect/UseConstructor.html
http://www.codeguru.com/java/tij/tij0049.shtml
Regards, Suresh KB
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.