In order to create a sub class for any Class, we have to write the following code manually as shown below -
public class SubClass extends SuperClass
{
}
Instead we can use the Eclipse IDE options to order to create a sub class for super class without writing the code manually. In order to understand how to use Eclipse IDE options to create a sub class, please following the below steps on Eclipse IDE.
Lets implement this on Eclipse IDE -
1. Launch Eclipse IDE, create a Java Project 'Project 27' as shown below -
2. Create a Java Class 'SuperClass' as shown below -
3. Lets create a sub class for the above created class 'SuperClass' using Eclipse IDE options by following the below steps.
4. Right click on the Java Project 'Project 27' and select 'New' -> 'Class' option as shown below -
5. In the 'New Java Class' dialog, enter 'SubClass' into the 'Name' field as shown below -
6. Enter the Class Name of the Class created in the above step #2 i.e. 'SuperClass' into the 'Superclass' field as shown below -
7. Click on 'Finish' button on the dialog as shown below -
8. Observe that the sub class inheriting super class code got generated automatically as shown below -
Please comment below to feedback or ask questions.
No comments:
Post a Comment