Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

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_2

Step: 3

blur-text-image_3

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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions

Question

Why is strict liability rare in Canadas tort regime?

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago