Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //1st code
- class ABC{
- public ABC() {
- }
- public void myMethod() {
- System.out.println("Overridden method");
- }
- }
- class Demo extends ABC{
- public Demo() {
- }
- @Override
- public void myMethod(){
- super.myMethod();
- System.out.println("Overriding method");
- }
- public static void main(String args[]) {
- ABC obj1 = new ABC();
- Demo obj2 = new Demo();
- obj1.myMethod();
- obj2.myMethod();
- }
- }
- //2nd code
- class Base{
- public Base() {
- }
- void demo (int a){
- System.out.println ("a: " + a);
- }
- void demo (int a, int b){
- System.out.println ("a and b: " + a + "," + b);
- }
- double demo(double a) {
- System.out.println("double a: " + --a);
- return a*a;
- }
- }
- class Test{
- public static void main (String args []){
- Base Obj = new Base();
- double result;
- Obj.demo(10);
- Obj.demo(10, 20);
- result = Obj.demo(5.5);
- System.out.println("O/P : " + ++result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement