Analyze the following code.

```
public class Test {
int x;

public Test(String t) {
System.out.println("Test");
}

public static void main(String[] args) {
Test test = new Test();
System.out.println(test.x);
}
}
```
a. The program has a compile error because System.out.println method cannot be invoked from the constructor.
b. The program has a compile error because x has not been initialized.
c. The program has a compile error because you cannot create an object from the class that defines the object.
d. The program has a compile error because Test does not have a default constructor.

d. The program has a compile error because Test does not have a default constructor.
Note that a default no-arg constructor is provided only if no constructors are explicitly defined in the class. In this case, a constructor Test(String t) is already defined. So, there is no default no-arg constructor in the Test class.

Computer Science & Information Technology

You might also like to view...

You can create an icon to an application on your computer, but not to a specific folder

Indicate whether the statement is true or false

Computer Science & Information Technology

The Whois tools help to determine who, where, and when a domain or site was registered—and the information about those who support it now.

a. true b. false

Computer Science & Information Technology