Question: What is wrong in the following code? public class Test {public static void main(String[] args) {method1(); private static void method1() {Circle c; System.out.println(What is radius

 What is wrong in the following code? public class Test {public

What is wrong in the following code? public class Test {public static void main(String[] args) {method1(); private static void method1() {Circle c; System.out.println("What is radius " + c_middot getRadius()); method should be declared before main, since it is used in main, method is a private method and cannot be invoked in the main method. The program has a compilation error in the println 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 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 Databases Questions!