Question: 6. What is wrong in the following code? public class Test ( a. b. c. d. public static void main(String[] args) { methodl ();

6. What is wrong in the following code? public class Test ( 

6. What is wrong in the following code? public class Test ( a. b. c. d. public static void main(String[] args) { methodl (); } private static void methodl () { Circle c; System.out.println ("What is radius " + c.getRadius ()); } } methodl should be declared before main, since it is used in main. methodl is a private method and cannot be invoked in the main method. The program has a compilation error in the printin statement where c has not been initialized. The program compiles fine, but it has a runtime error because variable c has not been initialized.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

This is a code snippet written in Java showing a class Test with a main method that calls another me... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!