public class Base {
public void myMethod(int a,intb) {}
}
// Uses myMethod and then hides it.
public class DerivedOne extends Base {
private void myMethod(int a,int b);
}
will this compile or not .yes or no. why
Answers were Sorted based on User's Feedback
Answer / ashwin khandelwal
It cannot be compiled because of weaker access privilege give to method in DerivedOne class while overidding method of Base Class
| Is This Answer Correct ? | 12 Yes | 0 No |
Answer / narayana
This will not compile because in the base class myMethod()
function is not having the body ,only abstract methods
should not have the body remaining all methods should have
the body
| Is This Answer Correct ? | 6 Yes | 6 No |
What is the purpose of skeleton and stub?
How to declare an arraylist in java?
what is different between static and non static methods ,using example
What is the use of arraylist class in java?
What is mean by collections in java?
Write a java program to check if a number is prime or not?
What is the difference between notify and notifyall method?
How to perform quicksort in java?
In Java, what types of classes perform inheritance?
how and when compiler knows that the Java code throws the checked Exception.
Can interface be private in java?
What is meant by class loader? How many types are there? When will we use them?