what is the use of a super keyword?
Answers were Sorted based on User's Feedback
Answer / sobhanadri.15
super keyword is used for accessing the variables in the
construtor of the subclass
| Is This Answer Correct ? | 5 Yes | 1 No |
Answer / swamireddy
the super keyword is used for accessing a base class
constructor values of the sub class.actually constructor
values are not inherited to the derived class.the super
keyword using inherited easily
for example:
import java.io.*;
class a
{
int x,y;
a(int i,int j)
{
x=i;
y=j;
System.out.ptintln(" "+x+" "+y);
}
}
class b extends a
{
int g;
b(int i,int j)
{
super(i,j);
g=i+i*(j*j);
System.out.println(g);
}
}
class mab
{
public static void main(String args[])
{
b ob=new b(24,2);
}
}
output:
24 2
48 4
| Is This Answer Correct ? | 7 Yes | 4 No |
Answer / prem chawla
super keyword is refer to the parent class object it means
it can acc0ess all properties of the parent object
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / upasana das
example of inheritance using super keyword
class a
{
int x,y;
a(int i,int j)
{
x=i;
y=j;
System.out.println(" "+x+" "+y);
}
}
class b extends a
{
int g;
b(int i,int j)
{
super(i,j);
g=i+i*(j*j);
System.out.println(g);
}
}
class mab
{
public static void main(String args[])
{
b ob=new b(24,2);
}
}
output: 24 2
120
| Is This Answer Correct ? | 2 Yes | 2 No |
Why do we create dto in java?
What are java’s rules regarding tabs, spaces and newline characters?
Which is best framework in java?
what is jdbc?
what are the types of constructer explain with example
What is flatmap in java8?
What is transient in java?
Name primitive java types.
Can optional be null?
What's the difference between local, global and universal groups? : java security
What are jpa repositories?
What does public static void main(string[]) mean?