Valid Java Constructor Calls
Consider the following Student class declaration.
public class Student
{
private String myName;
private int myAge;
public Student()
{ /* implementation not shown */ }
public Student(String name, int age)
{ /* implementation not shown */ }
// No other constructors
}
Which of the following variable declarations will compile without error?
I. Student a = new Student();
II. Student b = new Student("Juan", 15);
III. Student c = new Student("Juan", "15");
A
II only
B
I and II only
C
I only
D
I and III only
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | chunxiangxu.cxu | 1 | 1 | 0m 10s | 90 |
| #2 | y.seong2027 | 2 | 3 | 2m 22s | 48 |
| #3 | songqiuhui2012 | 0 | 1 | 0m 04s | -14 |
| #4 | 6test6ing6 | 0 | 2 | 0m 00s | -20 |
| #5 | suhanakochhar006 | 1 | 3 | 18m 05s | -1,005 |
| #6 | bommasam000 | 4 | 4 | 5h 54m | -20,857 |
Items per page:
10
1 – 6 of 6
APFIVE