What is the output of line 1 of the above code? 6. (constructor) Assume that the
ID: 3720682 • Letter: W
Question
What is the output of line 1 of the above code? 6. (constructor) Assume that the class President is correct: public class President private String gender; private double income; private int id; public President(int yid-y; income 100.0; public President(double x)(incomde x; gender y: public President(String wincomde 0.00; genderw:? public class President Tester public static void main(Stringl] argsf President trump - new President ("trump", 200); //line 1 President trump new President (200.15);//line 2 President trump new President ("trump"); //line 3 President trump new President (100); /line 4 won't be compiled a.Line 1 b.Line 2 c. Line 3 d.Line 4 7. (relationships)Explanation / Answer
a. Line 1
President trump = new President("trump",200);
It will not compile as two argument constructor is not defined in the class President.
b. Line 2
President trump = new President(200.15);
It will compile as one argument constructor with argument type double is defined in the class President.
c. Line 3
President trump = new President("trump");
It will compile as one argument constructor with argument type String is defined in the class President.
d. Line 4
President trump = new President(100);
It will compile as one argument constructor with argument type int is defined in the class President.
thus correct answer is:
a. Line 1?
?Do ask if any doubt. Please upvote.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.