Method Overriding Program
class person
{
String name="Allprogramexample";
int age =23;
void result()
{
System.out.println("name is"+name+"age is"+age);
}}
class student extends person
{
int marks=1800;
void result() //method overrading
{
System.out.println("name is"+name+"age is"+age+"marks is "+marks);
}}
public class mov
{
public static void main(String aa[])
{
student obj1=new student();
obj1.result();
}}
class person
{
String name="Allprogramexample";
int age =23;
void result()
{
System.out.println("name is"+name+"age is"+age);
}}
class student extends person
{
int marks=1800;
void result() //method overrading
{
System.out.println("name is"+name+"age is"+age+"marks is "+marks);
}}
public class mov
{
public static void main(String aa[])
{
student obj1=new student();
obj1.result();
}}
0 comments:
Post a Comment