Answered step by step
Verified Expert Solution
Question
1 Approved Answer
What is the output of the following program? public class Gen { G g; Gen(G g) { this.g =g; } public static void main(String[] args)
What is the output of the following program?
public class Gen { G g; Gen(G g) { this.g =g; } public static void main(String[] args) { Gen arr[] = new Gen[5]; //line 1 arr[0] = new Gen("Java"); //line 2 arr[1] = new Gen(1); //line 3 arr[2] = (Gen)new Gen(1); //line 4 arr[3] = (Gen)new Gen(1); //line 5 for(Gen o:arr) { System.out.println(o); } } }
a)Compile time Error at line 1
b)Compile time Error at line 3
c)Compile time Error at line 4
d)Compile time Error at line 5
e)Run Time Error
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started