inhuman_Arif

quiz

Aug 5th, 2021
578
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //1st code
  2. class ABC{
  3.     public ABC() {
  4.     }
  5.     public void myMethod() {
  6.         System.out.println("Overridden method");
  7.     }
  8. }
  9. class Demo extends ABC{
  10.     public Demo() {
  11.     }
  12.     @Override
  13.     public void myMethod(){
  14.         super.myMethod();
  15.         System.out.println("Overriding method");
  16.     }
  17.     public static void main(String args[]) {
  18.         ABC obj1 = new ABC();
  19.         Demo obj2 = new Demo();
  20.         obj1.myMethod();
  21.         obj2.myMethod();
  22.     }
  23. }
  24.  
  25. //2nd code
  26. class Base{
  27.     public Base() {
  28.     }
  29.     void demo (int a){
  30.         System.out.println ("a: " + a);
  31.     }
  32.     void demo (int a, int b){
  33.         System.out.println ("a and b: " + a + "," + b);
  34.     }
  35.     double demo(double a) {
  36.         System.out.println("double a: " + --a);
  37.         return a*a;
  38.     }
  39. }
  40. class Test{
  41.     public static void main (String args []){
  42.         Base Obj = new Base();
  43.         double result;
  44.         Obj.demo(10);
  45.         Obj.demo(10, 20);
  46.         result = Obj.demo(5.5);
  47.         System.out.println("O/P : " + ++result);
  48.     }
  49. }
RAW Paste Data