Consider the following class:
1. class MyClass { 2. void myMethod(int i) { 3. System.out.println("int version"); 4. } //from w ww . j a va 2s.co m 5. void myMethod(String s) { 6. System.out.println("String version"); 7. } 8. 9. public static void main(String args[]) { 10. MyClass crun = new MyClass(); 11. char ch = 'p'; 12. crun.myMethod(ch); 13. } 14. }
Which of the following statements is true? (Choose one.)
myMethod()
takes a char argument. D.
At line 12, the char argument ch is widened to type int (a method-call conversion) and passed to the int version of method myMethod()
.