JavaGian java tutorial and java interview question and answer

JavaGian , Free Online Tutorials, JavaGian provides tutorials and interview questions of all technology like java tutorial, android, java frameworks, javascript, ajax, core java, sql, python, php, c language etc. for beginners and professionals.

Showing posts with label inheritance. Show all posts
Showing posts with label inheritance. Show all posts

Core java inheritance Explanation with example

3:42 AM
Inheritance can be defined as the process where one class acquires the properties (methods and fields) of another. With the use of inheritance the information is made manageable in a hierarchical order. The class which inherits the properties of other is known as subclass (derived class, child class) and the class whose properties are inherited is known as superclass (base class, parent class). extends Keyword extends  is the keyword used to inherit the properties of a class. Following is the syntax of extends keyword. Syntax class Super { ..... ..... } class Sub extends Super { ..... ..... } Sample Code Following is an example demonstrating Java inheritance. In this example, you can observe two classes namely Calculation and My_Calculation. Using extends keyword, the My_Calculation inherits the methods addition() and Subtraction() of Calculation class. Copy and paste the following program in a file with name My_Calculation.java Example  Live Demo cla

.