cancel
Showing results for 
Search instead for 
Did you mean: 

constructor

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

suresh_krishnamoorthy
Active Contributor
0 Kudos

Answers (0)