0% found this document useful (0 votes)
17 views

Super Keyword in Java (Based Class)

The document discusses the super keyword and static keyword in Java. The super keyword refers to the immediate parent class object and is used to invoke parent class methods or constructors. The static keyword applies to variables, methods, blocks and nested classes and belongs to the class rather than object instances. Static variables are class variables that get memory only once and can be used for common properties not unique to each object.

Uploaded by

Aakash
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Super Keyword in Java (Based Class)

The document discusses the super keyword and static keyword in Java. The super keyword refers to the immediate parent class object and is used to invoke parent class methods or constructors. The static keyword applies to variables, methods, blocks and nested classes and belongs to the class rather than object instances. Static variables are class variables that get memory only once and can be used for common properties not unique to each object.

Uploaded by

Aakash
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Super Keyword in Java(Based class)

The super keyword in Java is a reference variable which is used to refer immediate
parent class object.

Whenever you create the instance of subclass, an instance of parent class is created
implicitly which is referred by super reference variable.

Usage of Java super Keyword


1. super can be used to refer immediate parent class instance variable.

2. super can be used to invoke immediate parent class method.

3. super() can be used to invoke immediate parent class constructor.

Java static keyword


The static keyword in Java is used for memory management mainly. We can apply java
static keyword with variables, methods, blocks and nested class. The static keyword
belongs to the class than an instance of the class.

The static can be:

1. Variable (also known as a class variable)

2. Method (also known as a class method)

3. Block

4. Nested class

1) Java static variable


If you declare any variable as static, it is known as a static variable.

o The static variable can be used to refer to the common property of all objects
(which is not unique for each object), for example, the company name of
employees, college name of students, etc.

o The static variable gets memory only once in the class area at the time of class
loading.

Advantages of static variable

It makes your program memory efficient (i.e., it saves memory).

You might also like