Can someone help me why the following code does not compile. Why not? public class WIDGET
Question:
Can someone help me why the following code does not compile. Why not?
public class WIDGET
{ private String x = '';
private static final int Y = 10;
public String getX() {
return x; }
public void setY(int aNumber)
{ Y = aNumber; }
public void SETX(String aString)
{ x = aString; }
public void addToX(String x)
{ x = this.x + x; }
}
Possible answers below:
The method addToX does not set the instance variable x to a new value.
The method getX should have a parameter.
The declaration of the field Y is not valid.
In setY It is illegal to assign a value to field Y.
The method SETX does not follow naming conventions.
There is a brace (curly bracket) too many.
There is no constructor.
In the addToX method the + operator is being applied to strings.
The class name is not valid.
The field x is not correctly initialised.
OCP Oracle Certified Professional Java SE 11 Developer Practice Tests Exam 1Z0 819 And Upgrade Exam
ISBN: 9781119696131
1st Edition
Authors: Scott Selikoff, Jeanne Boyarsky