Home > Java > javaTutorial > DayInheritance:

DayInheritance:

Barbara Streisand
Release: 2024-12-31 06:44:10
Original
295 people have browsed it

INHERITANCE:

 * Inheritance is implemented using the extends keyworrds.

 * Inheritance in java is a mechanism where one class child or subclass acquires the properties and behaviors fields and methods of another class parent or superclass.

 * subclass (child) - the class that inherits from another class

 * superclass (parent) - the class being inherited from To inherit from a class, use the extends keyword. # 
Copy after login

Example program:

package reegan;
class Dad
Copy after login

{
int money=2000;
}
class son extends dad
{

}
public class mainclass
{
public static void main(String []args)
{
son s1=new son();
System.out.println(s1.money);
}
}

DayInheritance:

The above is the detailed content of DayInheritance:. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template