package com.company;
import java.util.Scanner;
class Accesspecifer
{
//access specifers
private int rollno;
private int age;
public void get (int a,int y)
{
rollno=y;
age=a;
}
public void set ()
{
System.out.println("your age is: "+age);
System.out.println("your roll no is: "+rollno);
}
}
public class Program42 {
public static void main(String[] args) {
Accesspecifer obj=new Accesspecifer();
Scanner p = new Scanner(System.in);
System.out.println("please enter your age here:");
int x=p.nextInt();
System.out.println("please enter your roll no here:");
int b=p.nextInt();
obj.get(x,b);
obj.set();
}
}
Hi Friends ! You are on HR Developers website. Here you can find the codes of different languages like c ,c++ , java, pyton and many other languages.
Friday, July 2, 2021
simple program on access specifier (Java) (205)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment