Ask Question
29 September, 03:34

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

}

}

+2
Answers (1)
  1. 29 September, 03:38
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers