Nội dung text JPR IMP Programs.pdf
3. Method Overloading class Demo { void show(int a) { System.out.println("Integer: " + a); } void show(int a, int b) { System.out.println("Sum: " + (a + b)); } public static void main(String[] args) { Demo obj = new Demo(); obj.show(10); obj.show(10, 20); } } 4. Method Overriding class Parent { void show() { System.out.println("Parent class method"); } } class Child extends Parent { @Override void show() { System.out.println("Child class method"); } public static void main(String[] args) { Parent obj = new Child(); obj.show();