Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

anmol meghadambar

Greenhorn
+ Follow
since May 24, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by anmol meghadambar

please help me out ,Can we use throws with unchecked exception?

Praveen Kumar M K wrote:

yes we cant override static method i got the answer but we can redefine into sub class with same signature and it will create two copies of static methods



No these are 2 different static methods (albeit having the same signature), not copies.




yes I got the answer thank you Praveen.....
Thank you Seetharaman Venkatasamy and gurpeet singh for replay me.....

yes we cant override static method i got the answer but we can redefine into sub class with same signature and it will create two copies of static methods

code:-
class SuperClass
{

public static void get()
{
System.out.println("In Super Class");

}

}
public class SubClass extends SuperClass
{
public static void get()
{
System.out.println("In Sub Class");

}
public static void main(String a[])
{
SuperClass superobj=new SuperClass();
SubClass subobj=new SubClass();

superobj=new SubClass();
superobj.get();

subobj.get();


}
}
/*output:-
In Super Class
In Sub Class*/

If we override static method then how many copies are created of static method?