what is the use of a super keyword?

Answers were Sorted based on User's Feedback



what is the use of a super keyword?..

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

what is the use of a super keyword?..

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

what is the use of a super keyword?..

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

what is the use of a super keyword?..

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

Post New Answer

More Java Related AllOther Interview Questions

What if I do not provide the string array as the argument to the method?

0 Answers  


how can program polindrome using java

1 Answers  


i have client interview in TCS.client is CITI BANK.how to face it,what type of questions they will ask,please tell send me to kumar525job@gmail.com

0 Answers   TCS,


i have make jar file but when i click in this file then arr swhow "no faund main class" plese help me in this problem becose i want to make a jar file as a dxdcutable file

1 Answers  


what is the package for freshers in valuelabs.

0 Answers  






How does jpa repository work?

0 Answers  


How do I install java on windows?

0 Answers  


Is java secure? : java security

0 Answers  


what type of java questions asked?

1 Answers  


cant we call run() method directly instead of calling indirectly through the start() method ? if we do so then what is the problem ?

7 Answers   HSBC, Subex,


What is javax annotation generated?

0 Answers  


What is the difference between Object Code and ByteCode? Why do people keep saying that bytecode is like the intermediate of source and object code? Also, which is better/commonly used and why? Please keep in mind that I am a beginner, please keep all terminology fairly simple. Thanks!

1 Answers  


Categories