Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

class A{
m2(){
}
}
class B extends A{
m2(){
}
}
class c extends B{
m2(){
}
}
class my_class extends c{
m2(){
}
pulic static void main(){

...My_class a = new my_class();
super.super.super.m2(); is this is leagal
if not find what is the legal procedure in order to call A's
version of m2();

}

Answer Posted / n. bala subramanian

By reflection we can achive it, I hope this is correct


class A{
void m2(){System.out.println("in class A");}
}

class B extends A{
void m2(){System.out.println("in class B");}
}
class C extends B{
void m2(){ System.out.println("in class c");}
}

public class Test extends C {
void m2(){System.out.println("in class A"); }
public static void main(String[] args) throws Exception{
Class c = Class.forName("com.samples.test.Test");
A obj = (A) c.getSuperclass().getSuperclass
().getSuperclass().newInstance();
}
}

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to one war file class to another war file class?

2076


What is null mean in java?

1097


When a thread is executing synchronized methods , then is it possible to execute other synchronized methods simultaneously by other threads?

1064


What is the final blank variable?

1137


Which one will take more memory: an int or integer?

1235


What is difference between static variable and global variable?

1065


When is the garbage collection used in Java?

1202


What is the argument in java?

919


Is int a class in java?

985


Write a program in java to create a doubly linked list containing n nodes.

969


What is indexof in java?

1002


What is output buffer?

1052


What are the different http methods?

1034


What is a default constructor and also define copy contrucyor?

1108


What are desktop procedures?

1044