Given the code fragment:
Which two modifications, when made independently, enable the code to print joe:true: 100.0?
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
Given the code fragment:
Which two modifications, when made independently, enable the code to print joe:true: 100.0?
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
AC
public class Q126 {
String name;
double salary;
boolean contract;
Q126 (){
//C
this.name = new String(“Joe”);
this.contract=new Boolean(true);
this.salary=new Double(100);
//D is correct if contract is true
// name=”Joe”;
// salary = 100.0f;
// contract = TRUE;//fail to compile TRUE
}
public String toString(){
return name +”:”+contract+”:”+salary;
}
public static void main(String[] args) {
Q126 e = new Q126();
//A
e.name=”Joe”;
e.salary=100.0;
e.contract=true;
System.out.println(e);
}
AC