Ask Question
25 May, 07:38

Analyze the following code:

public class Test {

public static void main (String[] args) {

A a = new A ();

a. print ();

}

}

class A {

String s;

A (String newS) {

s = newS;

}

void print () {

System. out. println (s);

}

}

+4
Answers (1)
  1. 25 May, 09:21
    0
    Constructor issue

    Explanation:

    When you look at the Class A, the constructor takes one argument as a parameter, a String.

    A (String newS) {

    s = newS;

    }

    However, in the main, the constructor does not take any argument as a parameter.

    A a = new A ();

    That's why the code does not compile.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Analyze the following code: public class Test { public static void main (String[] args) { A a = new A (); a. print (); } } class A { String ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers