posted 11 years ago
public static void main (String... arg) throws Exception {
B.sleep();
// the output is "I want to sleep, it is late"
//and if you activate sleep method in B the output will be "B"
}
}
class A {
public static void sleep() {
System.out.println("I want to sleep, it is late");
}
}
class B extends A{
/*
public static void sleep() {
System.out.println("B");
}
*/
}
// there is no object there So What is happened
B.sleep();
// the output is "I want to sleep, it is late"
//and if you activate sleep method in B the output will be "B"
}
}
class A {
public static void sleep() {
System.out.println("I want to sleep, it is late");
}
}
class B extends A{
/*
public static void sleep() {
System.out.println("B");
}
*/
}
// there is no object there So What is happened

SCJP 5
posted 11 years ago
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
