Home Tutorial Java Scjp Part4 SCJP Module-4 Question-2

 
 

SCJP Module-4 Question-2
Posted on: July 9, 2010 at 12:00 AM
The given example checks you concept of method overriding in Java and help you in understanding of overriding concept in Java.

Given the following sample code:

class Example2 {

void Twin(int x, float y) { }

}

class SubExample2 extends Example2{
public void Twin(int x, float y) { }
}

Is the following code correct ,with same name methods with same number of arguments ? Choose correct option :

1. Correct code , method overriding is used.

2. Methods can't have the same name.

3. Methods can have same name but arguments must be different.

4. Will throw Exception.

Answer :

(1)

Explanation :

In this code , method overriding is used. In method overriding , method of super class with same name & same number of arguments ,can be used in  subclasses.

Related Tags for SCJP Module-4 Question-2:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.