Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

More Books

Students also viewed these Databases questions