package scope;

import java.util.Scanner;

class person
{private String name;
int adharno;
person()
{
    System.out.println("Base class constructor invoked");
   
   
}
private    void getAdharno(int no,String s)
    {
        adharno=no;
        name=s;
    }
   protected void getdata(int num,String s)
    {
      getAdharno(num,s);
       
    }
  
   void display()
   {
       System.out.println(adharno+"   "+name);
   }
}

public class student extends person{
    int rollno;
    String year;
    String branch;
    student()
    {super();
   
    System.out.println("Enter Roll No");
    Scanner s=new Scanner(System.in);
    rollno=s.nextInt();
   
    }
    void display()
    {super.display();
        System.out.println("Derived class method invoked"+rollno);
       
    }
    public static void main(String args[])
    {
        student s=new student();
   
       
        System.out.println("Enter Adhar  No");
        Scanner s1=new Scanner(System.in);
        int n1=s1.nextInt();
        System.out.println("Enter name");
        String name=s1.next();
        s.getdata(n1,name);
        s.display();
    }

}

Popular posts from this blog

DDL DML DCL and TCL

Implementation of Calculator using lex and yacc

A Register Allocation algorithm that translates the given code into one with a fixed number of registers.