Linked Questions

11 votes
5 answers
49k views

I am trying to understand why we can't override static and final methods. I do not get the purpose behind it.
user avatar
6 votes
2 answers
813 views

Possible Duplicate: Why doesn't Java allow overriding of static methods? Is there any legitimate reason why one would want a derived class to override hide a static method of the base class?
Saket's user avatar
  • 46.3k
1 vote
5 answers
2k views

class A{ public static void staticMethod(){ System.out.println("Static method of A"); } } class B extends A{ public static void staticMethod(){ System.out.println("Static ...
Pankaj's user avatar
  • 15.6k
1 vote
2 answers
3k views

Possible Duplicates: Why can’t static methods be abstract in Java Static methods and their overriding Why doesn’t Java allow overriding of static methods ? Can we override static ...
Sun Java its my life 's user avatar
3 votes
4 answers
948 views

From question three in these OCA practice questions (pdf): abstract class Writer { public static void write() { System.out.println("Writing..."); } } class Author extends Writer { ...
Rick's user avatar
  • 136
2 votes
1 answer
2k views

class Abc{ public static void hello(){ System.out.println("parent");//Line1 } } class Abc1 extends Abc{ public void hello(){//Line2 System.out.println("child");//Line3 } } Compiler gives ...
Prasad's user avatar
  • 1,177
0 votes
4 answers
452 views

When I try running this piece of code, it gives me 30. Can someone please explain!I know you can't override static methods in Java, because, polymorphism and static won't work together. And static ...
loreen99's user avatar
2 votes
2 answers
282 views

I can't understand why compiler shows an error when I try compile this code : class A { public static void f() { System.out.println("A.f()"); } } class B extends A { public ...
Az.Youness's user avatar
  • 2,767
-1 votes
2 answers
1k views

I have superclass Token with some subclasses like Knight, King, Queen, etc. I need a random Token Type so I call this method: public Class randomTokenType(){ Class[] classes = { Bishop....
jesper's user avatar
  • 1
-1 votes
1 answer
511 views

I have a old code which is like this- Public class ABC{ . . . Public static class InnerClass{ Public static method do something(){ } } } I want to override do something() method in ...
Rahul Vedpathak's user avatar
-2 votes
2 answers
170 views

class B extends A { static public void printMe(){ System.out.println("in static B"); } } class A{ static public void printMe(){ System.out.println("In static A"); } } ...
robin's user avatar
  • 1,925
0 votes
4 answers
362 views

Here if I try to override a static method without using static in the subclass it gives me an error.. while this is not a case with static variable. Why? class A { static int a; static void a(...
NeelPatwa's user avatar
  • 303
-2 votes
1 answer
90 views

Trying to work on an example from a book on method overriding. The code has two classes Veggies and Pumpkin.The only confusion i have is if the object of pumpkin is assigned to the myveggie object, ...
Bissi singh's user avatar
-1 votes
3 answers
80 views

public class Base { private static boolean goo = true; protected static boolean foo() { goo = !goo; return goo; } public String bar = "Base:" + foo(); public ...
student's user avatar
  • 25
0 votes
0 answers
95 views

I have started learning Java, and have come across this example, on this page: abstract class Writer { public static void write() { System.out.println("Writing..."); } } class Author extends ...
Leff's user avatar
  • 1,610

15 30 50 per page
1
2 3 4 5
7