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 |
How many JVMs can run on a single machine and what is the Just-In-Time(JIT) compiler?
What is difference between == equals () and compareto () method?
when to use abstract class and when to use interface?
16 Answers Exterro, iGate, IonIdea,
What is <> used for in java?
What is the latest version of java?
Where to store local variables?
Can we increase array size dynamically in java?
How do you achieve polymorphism in java?
What is variable and rules of variable?
Print Vertical traversal of a Binary Tree.
Write java code to print "Hello how are you" Thread1 should have "Hello" Thread2 should have "how are you" both the threads should start at the same time
What is the difference between this() and super() in java?