Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 ( 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

Step: 1

This is a code snippet written in Java showing a class Test with a main method that calls another me... 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

Introduction To Programming With Java A Problem Solving Approach

Authors: John Dean

3rd International Edition

1260575241, 9781260575248

More Books

Students also viewed these Programming questions