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

 
 

Share on Google+Share on Google+
SCJP Module-4 Question-2
Posted on: July 9, 2010 at 12:00 AM
Advertisement
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.

Advertisement

Related Tags for SCJP Module-4 Question-2:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 9, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com