Exam Permalink:
https://www.jobilize.com/java-certification-questions
Question Permalink:
https://www.jobilize.com/java-overloading-rules
Question 66 / 297:  What modification is necessary to produce the following output : SubType
class Type {

public Object getTypeName(){

return "Type";

}

}

class SubType extends Type {

public String getTypeName(){//line 8

return "SubType";

}

}

public class Tester {

public static void main(String[] args) {

Type first = new SubType(); //line 16

System.out.println(first.getTypeName()); //line 17

}

}

A  No modification is needed
B  At line 8 change ´the return type from String to Object to be a correct overloading of
getTypeName()
C  At line 16 change Type to SubType
D  At line 17 cast first.getTypeName() to String
<< First < Previous Next > Last >>
Exam Home Page
https://www.jobilize.com/java-certification-questions

Oracle Certified Professional Java Programmer

Author:

Access: Public Instant Grading

Ask
Copy and paste the following HTML code into your website or blog.
<iframe src="https://www.jobilize.com/embed/java-certification-questions" width="600" height="600" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes" style="border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px" allowfullscreen webkitallowfullscreen mozallowfullscreen> </iframe>