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 |
Does the order of public and static declaration matter in main method?
Can we sort hashmap in java?
What is the default initialized value of String type variable?
What is scope & storage allocation of static, local and register variables? Explain with an example.
What is the use of string and stringbuffer?
How the elements are organized in GridLayout?
Is java still necessary?
what is collections in java?
how are methods defined?
What is stream api in java8?
Can list be final in java?
when i write string s1="java"; in one program(application) and string s2="java"; in another application on the same jvm will both objects s2,s2 will refer to same memory location where "java" is stored in string pool.