Entri Blog
No Result
View All Result
Sunday, May 28, 2023
  • State PSC
    • Kerala PSC
    • TNPSC
    • APPSC
    • TSPSC
    • BPSC
    • Karnataka PSC
    • MPPSC
    • UPPSC
  • Banking
    • IBPS PO Notification
    • IBPS Clerk Notification
    • SBI PO Notification
    • SBI Clerk Notification
    • SBI SO Notification
    • SBI Apprentice Notification
    • Canara Bank PO Notification
    • Indian Bank PO Notification
    • RBI Assistant Notification
    • RBI Office Attendant Notification
    • IBPS RRB Notification
    • IBPS RRB Office Assistant Notification
  • Govt Exams
    • Railway
    • SSC
  • Skilling
    • Coding
    • Spoken English
    • Stock Marketing
  • TET
    • APTET
    • CTET
    • DSSSB
    • Karnataka TET
    • Kerala TET
    • KVS
    • MPTET
    • SUPER TET
    • TNTET
    • TSTET
    • UPTET
  • Courses
    • Data Science Course
      • Data Science Malayalam
    • Full Stack Developer Course
      • Full Stack Development Malayalam
      • Full Stack Development Hindi
      • Full Stack Development Tamil
      • Full Stack Development Telugu
      • Full Stack Development Kannada
    • Stock Market Course
      • Stock Market Course in Malayalam
      • Stock Market Course in Tamil
      • Options Trading Course
    • Spoken English Course
      • Spoken English Course in Malayalam
      • Spoken English Course in Hindi
      • Spoken English Course in Telugu
      • Spoken English Course in Tamil
      • Spoken English Course in Kannada
    • Python Programming Course
    • Practical Accounting Course
    • Quantity Surveying Course
  • Others
    • GATE
    • MAT
    • KMAT
    • UPSC
Try out Spoken English!
Entri Blog
  • State PSC
    • Kerala PSC
    • TNPSC
    • APPSC
    • TSPSC
    • BPSC
    • Karnataka PSC
    • MPPSC
    • UPPSC
  • Banking
    • IBPS PO Notification
    • IBPS Clerk Notification
    • SBI PO Notification
    • SBI Clerk Notification
    • SBI SO Notification
    • SBI Apprentice Notification
    • Canara Bank PO Notification
    • Indian Bank PO Notification
    • RBI Assistant Notification
    • RBI Office Attendant Notification
    • IBPS RRB Notification
    • IBPS RRB Office Assistant Notification
  • Govt Exams
    • Railway
    • SSC
  • Skilling
    • Coding
    • Spoken English
    • Stock Marketing
  • TET
    • APTET
    • CTET
    • DSSSB
    • Karnataka TET
    • Kerala TET
    • KVS
    • MPTET
    • SUPER TET
    • TNTET
    • TSTET
    • UPTET
  • Courses
    • Data Science Course
      • Data Science Malayalam
    • Full Stack Developer Course
      • Full Stack Development Malayalam
      • Full Stack Development Hindi
      • Full Stack Development Tamil
      • Full Stack Development Telugu
      • Full Stack Development Kannada
    • Stock Market Course
      • Stock Market Course in Malayalam
      • Stock Market Course in Tamil
      • Options Trading Course
    • Spoken English Course
      • Spoken English Course in Malayalam
      • Spoken English Course in Hindi
      • Spoken English Course in Telugu
      • Spoken English Course in Tamil
      • Spoken English Course in Kannada
    • Python Programming Course
    • Practical Accounting Course
    • Quantity Surveying Course
  • Others
    • GATE
    • MAT
    • KMAT
    • UPSC
No Result
View All Result
Entri Blog
Spoken English
banner top article banner top article
Home Articles

This and Super Keyword in Java- All You Need to Know

by Shibani Ghosh
November 20, 2022
in Articles, Data Science and Machine Learning, Digital Marketing, Java Programming, React Native
This and Super Keyword in Java- All You Need to Know
Share on FacebookShare on WhatsAppShare on Telegram

Java contains a list of keywords or reserved words which are also highlighted with different colors be it an IDE or editor in order to segregate the differences between flexible words and reserved words.

What is a Keyword?

In the Java programming language, a keyword is any one of 67 reserved words that have a predefined meaning in the language. Because of this, programmers cannot use keywords in some contexts, such as names for variables, methods, classes, or as any other identifier.

Examples of Keywords

abstract – Specifies that a class or method will be implemented later, in a subclass

boolean – A data type that can hold True and False values only

char – A data type that can hold unsigned 16-bit Unicode characters

continue – Sends control back outside a loop

Learn to code from industry experts! Enroll here

This keyword

This keyword in java in Java that is used to invoke constructor, methods, static members of the current class that cannot be used as an identifier. It is used to refer current-class’s instance as well as static members. It is a reserved keyword.

‘this’ can be used in various contexts as given below:

  • to refer instance variable of current class
  • to invoke or initiate current class constructor
  • can be passed as an argument in the method call
  • can be passed as argument in the constructor call
  • can be used to return the current class instance

 

For Example,

class Code{
int var;
void method(int var){
this.var = var;
}
}

We have a variable ‘var’ and a parameter ‘var’ inside the method function. If we want to assign the value of parameter ‘var’ to the variable ‘var’ inside the class then we have to use the this keyword. In technical terms we are using this keyword tw refer the instance of current class. “this” is a special keyword in Java that is used to refer to the instance of the current class.

Learn Coding in your Language! Enroll Here!

super keyword

Super constructor in java that is used to invoke constructor, methods of the parent class. This is possible only when one class inherits another class

‘super’ can be used in various contexts as given below:

  • super is a reserved keyword in java i.e, we can’t use it as an identifier.
  • super is used to refer super-class’s instance as well as static members.
  • super is also used to invoke super-class’s method or constructor.

For Example,

class A{
void methodP(){
// method
}
}
class B extends A{
void methodC(){
// method
}
}
class C extends B{
void methodGC(){
// method
}
}

In the above code snippet of multi-level inheritance class B extends class A, it implies class A is immediate parent of class B. Similarly class C extends class B and now class C has two parents i.e., class A and class B, where class B is immediate parent of class C. Using the “super” keyword, we can refer to the immediate parent class’s methods, constructor, instance variables, and many more.

Learn to code from industry experts! Enroll here

Similarities in this and super Keyword in Java

1) We can use this as well as super anywhere except static area. Example of this is already shown above where we use this as well as super inside public static void main(String[]args) hence we get Compile Time Error since cannot use them inside static area.
2) We can use this as well as super any number of times in a program.

3) “this” and “super” must be the first statement if used inside the constructor. This means we cannot call both statements in a single constructor.

Difference Between this and super Keyword in Java

“this” keyword in Java
“super” keyword in Java
1. “this” is an implicit reference variable keyword used to represent the current class.
1. “super” is an implicit reference variable keyword used to represent the immediate parent class.
2. “this” is to invoke methods of the current class.
2. “super” is used to invoke methods of the immediate parent class.
3. “this” is used to invoke a constructor of the current class.
3. “super” is used to invoke a constructor of the immediate parent class.
4. “this” refers to the instance and static variables of the current class.
4. “super” refers to the instance and static variables of the immediate parent class.
5. “this” can be used to return and pass as an argument in the context of a current class object.
5. “super” can be used to return and pass as an argument in the context of an immediate parent class object.

Python and Machine Learning Rectangle

Entri provides video classes as well on various important topics by the excellent faculties. One will get revision modules, monthly tests based on the classes. Entri provides an excellent platform with full-length mock tests including previous year question papers. It also gives you access to clarify your doubts.

Share61SendShare
Shibani Ghosh

Shibani Ghosh

Pouring out my thoughts through words!

Related Posts

IELTS Score for Ireland explained
Articles

IELTS Score for Ireland

May 18, 2023
basic statistics to start data science journey
Articles

Basic Statistics to Start Data Science Journey

May 18, 2023
IELTS Score for Australia
Articles

IELTS Score for Australia

May 18, 2023
Next Post
Types of Crypto Currency

Types of Crypto Currency

Discussion about this post

Latest Posts

  • PNB SO Recruitment 2023 Notification Out: Apply for 240 Posts
  • Kerala PSC Assistant Engineer Shortlist 2023 Out: Check PDF, Link
  • Top 10 Books for UPSC Preparation in Malayalam: A Comprehensive Guide
  • Kerala PSC Computer Assistant Grade 2 Shortlist 2023: PDF, Link
  • Kerala PSC Lower Division Clerk Shortlist 2023: PDF, Link

Trending Posts

  • states of india and their capitals and languages

    List of 28 States of India and their Capitals and Languages 2023 – PDF Download

    150837 shares
    Share 60332 Tweet 37708
  • List of Government Banks in India 2023: All you need to know

    62286 shares
    Share 24914 Tweet 15572
  • TNPSC Group 2 Posts and Salary Details 2022

    39785 shares
    Share 15914 Tweet 9946
  • KSDA Recruitment 2023 Apply Online for 9264 FDA SDA Posts – Qualification

    3269 shares
    Share 1308 Tweet 817
  • New Map of India with States and Capitals 2023

    29286 shares
    Share 11714 Tweet 7321

Courses

  • Data Science Course
  • Full Stack Developer Course
  • Data Science Course in Malayalam
  • Full Stack Developer Course in Malayalam
  • Full Stack Developer Course in Hindi
  • Full Stack Developer Course in Tamil
  • Full Stack Developer Course in Telugu
  • Full Stack Developer Course in Kannada

Company

  • Become a teacher
  • Login to Entri Web

Quick Links

  • Articles
  • Videos
  • Entri Daily Quiz Practice
  • Current Affairs & GK
  • News Capsule – eBook
  • Preparation Tips
  • Kerala PSC Gold
  • Entri Skilling

Popular Exam

  • IBPS Exam
  • SBI Exam
  • Railway RRB Exam
  • Kerala PSC
  • Tamil Nadu PSC
  • Telangana PSC
  • Andhra Pradesh PSC
  • MPPSC
  • UPPSC
  • Karnataka PSC
  • Staff Selection Commission Exam

© 2021 Entri.app - Privacy Policy | Terms of Service

No Result
View All Result
  • State PSC
    • Kerala PSC
    • TNPSC
    • APPSC
    • TSPSC
    • BPSC
    • Karnataka PSC
    • MPPSC
    • UPPSC
  • Banking
    • IBPS PO Notification
    • IBPS Clerk Notification
    • SBI PO Notification
    • SBI Clerk Notification
    • SBI SO Notification
    • SBI Apprentice Notification
    • Canara Bank PO Notification
    • Indian Bank PO Notification
    • RBI Assistant Notification
    • RBI Office Attendant Notification
    • IBPS RRB Notification
    • IBPS RRB Office Assistant Notification
  • Govt Exams
    • Railway
    • SSC
  • Skilling
    • Coding
    • Spoken English
    • Stock Marketing
  • TET
    • APTET
    • CTET
    • DSSSB
    • Karnataka TET
    • Kerala TET
    • KVS
    • MPTET
    • SUPER TET
    • TNTET
    • TSTET
    • UPTET
  • Courses
    • Data Science Course
      • Data Science Malayalam
    • Full Stack Developer Course
      • Full Stack Development Malayalam
      • Full Stack Development Hindi
      • Full Stack Development Tamil
      • Full Stack Development Telugu
      • Full Stack Development Kannada
    • Stock Market Course
      • Stock Market Course in Malayalam
      • Stock Market Course in Tamil
      • Options Trading Course
    • Spoken English Course
      • Spoken English Course in Malayalam
      • Spoken English Course in Hindi
      • Spoken English Course in Telugu
      • Spoken English Course in Tamil
      • Spoken English Course in Kannada
    • Python Programming Course
    • Practical Accounting Course
    • Quantity Surveying Course
  • Others
    • GATE
    • MAT
    • KMAT
    • UPSC

© 2021 Entri.app - Privacy Policy | Terms of Service