Varma has Published 54 Articles

Why can’t we override static methods in Java?

varma

varma

Updated on 30-Jul-2019 22:30:20

5K+ Views

Overloading is the mechanism of binding the method call with the method body dynamically based on the parameters passed to the method call.Static methods are bonded at compile time using static binding. Therefore, we cannot override static methods in Java.

How do I write method names in Java?

varma

varma

Updated on 30-Jul-2019 22:30:20

3K+ Views

While writing a method name we should follow the camel case i.e. first letter of the first word should be small and the first letters of the remaining (later) words should be capital. Example public class Test { public void sampleMethod() { ... Read More

What is Is-a relationship in Java?

varma

varma

Updated on 30-Jul-2019 22:30:20

1K+ Views

IS-A is a way of saying: This object is a type of that object. Let us see how the extends keyword is used to achieve inheritance.Examplepublic class Animal { } public class Mammal extends Animal { } public class Reptile extends Animal { } public class Dog extends Mammal { ... Read More

Are the private variables and private methods of a parent class inherited by the child class in Java?

varma

varma

Updated on 30-Jul-2019 22:30:20

988 Views

No, a child class can’t inherit private members of the parent class, it can inherit only protected, default, and public members of it. If you try it gives you a compile time error as: − Example class Super{ private int data = 30; ... Read More

Advertisements