Answers for "Is it possible to override or overload a static method in Java?"

0

can we overload a static method in java

package test.main;
 
public class TestOverload {
 
	public static void main(String args[]) {
 
		Base obj = new Derived();
          
	       obj.display();  
	       obj.print(); 
	}
 
}
 
class Base {
 
	public static void display() {
		System.out.println("Base Class Display Called");
	}
 
	public void print() {
		System.out.println("Base Class Print Called");
	}
}
 
class Derived extends Base {
 
	public static void display() {
		System.out.println("Derived Class Display Called");
	}
 
	public void print() {
		System.out.println("Derived Class Print Called");
	}
}
Posted by: Guest on June-19-2020
0

can you override static methods in java

no, this is why you cannot use static methods in interfaces.
Posted by: Guest on September-13-2021

Code answers related to "Is it possible to override or overload a static method in Java?"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language