Java questions 3-4

3) What is method overriding in java ?

If we have methods with same signature (same name, same signature, same return type) in super class and subclass then we say subclass method is overridden by superclass.

When to use overriding in java

If we want same method with different behaviour in superclass and subclass then we go for overriding.

When we call overridden method with subclass reference subclass method is called hiding the superclass method.

4) What is super keyword in java ?

Variables and methods of super class can be overridden in subclass . In case of overriding , a subclass object call its own variables and methods. Subclass cannot access the variables and methods of superclass because the overridden variables or methods hides the methods and variables of super class.

But still java provides a way to access super class members even if its members are overridden. Super is used to access superclass variables, methods, constructors.

Super can be used in two forms :

1) First form is for calling super class constructor.

2) Second one is to call super class variables,methods.

Super if present must be the first statement.

要查看或添加评论,请登录

Hasan Kocaman的更多文章

  • JDBC

    JDBC

    ? JDBC: Sun firmas?n?n ticari markas?d?r. ? Java Database Connectivity (Java Veritaban? Ba?lant?s?) ? JDBC, Java…

  • Java question 6

    Java question 6

    Difference between abstract class and interface ?

  • Postman using JavaScript

    Postman using JavaScript

    https://learning.postman.

  • Selenium - Advanced Browser Configuration

    Selenium - Advanced Browser Configuration

  • Selenium - Driver Initilization

    Selenium - Driver Initilization

  • Java Questions 5

    Java Questions 5

    Difference between method overloading and method overriding in java ?

  • git-github medium makale

    git-github medium makale

    https://www.mobilhanem.

  • API

    API

    Authentication who you are ehliyetimin on yuzu isim soy isim Autherization what you can do ehliyetin arkasi hangi…

  • Java questions

    Java questions

    1) What are static blocks and static initalizers in Java ? Static blocks or static initializers are used to initalize…

  • Jira'ya stepleri aktarmanin kolay yolu

    Jira'ya stepleri aktarmanin kolay yolu

    Excelden Jira'ya steplerinizi direk kopyalayabiliyorsunuz. Once testcase olusturun sonra add stepin yaninda importtaki…

    2 条评论

社区洞察

其他会员也浏览了