Question:

I need help with this question?

by  |  earlier

0 LIKES UnLike

Look at the following code. The method in line _______ will override the method in line _______.

Line 1 public class ClassA

Line 2 {

Line 3 public ClassA() {}

Line 4 public int method1(int a){}

Line 5 public double method2(int b){}

Line 6 }

Line 7 public ClassB extends ClassA

Line 8 {

Line 9 public ClassB(){}

Line 10 public int method1(int b, int c){}

Line 11 public double method2(double c){}

Line 12 }

a. 10, 4

b. 11, 5

c. Both a and b

d. None of the above

 Tags:

   Report

2 ANSWERS


  1. D. The ClassB methods would override the ClassA ones if they were identical in both name and parm type/number. Since they use differing sets of parameters, these are completely separate functions as far as the compiler is concerned. If the ClassB method2 function had specified method2(int c) instead of a double, then the correct answer would have been B.


  2. C

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.