Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 8th, 2008, 01:43 AM
Authorized User
 
Join Date: Oct 2007
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to hafizmuhammadmushtaq Send a message via Yahoo to hafizmuhammadmushtaq
Default how to extend classes

i want to extend a class, but i am unable to do this........here is my code.......plz check it n tell if there are any errors

public class MyExercise{
    int e;
    public void mul(int c, int d){
        e = c*d;
    }
    public int getMul(){
        return e;
    }
    public class ChildClass extends MyExercise{
        public void childMethod(){
            System.out.println("Inside Child Class");
        }
    }
    public static void main(String args[]){
        MyExercise myObj = new MyExercise();
        myObj.mul(10,20);
        int get = myObj.getMul();
        System.out.println(get);
        ChildClass obj = new ChildClass();
        obj.childMethod();

    }
}


 
Old April 8th, 2008, 02:45 AM
jomet
Guest
 
Posts: n/a
Default

after
 public int getMul(){
        return e;
    }
put a '}'

remove the end '}' also

jomet.
---------------------------------------------
Once you start a working on something,
dont be afraid of failure and dont abandon it.
People who work sincerely are the happiest.





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to extend the String class hafizmuhammadmushtaq Java Basics 2 April 7th, 2008 06:21 AM
Extend a border nloding CSS Cascading Style Sheets 1 September 1st, 2006 08:43 PM
Cannot implement or extend Rusk Apache Tomcat 1 June 16th, 2004 06:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.