Ask Question
24 August, 03:53

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);

}

}

+5
Answers (1)
  1. 24 August, 07:29
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers