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.
(1)
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.
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.