package com.company;
import java.util.Scanner;
class paraconstructors
{
private int id;
private int age;
public paraconstructors(int x,int y) //default constructor
{
id=x;
age=y;
}
public void set ()
{
System.out.println("your age is: "+age);
System.out.println("your roll no is: "+id);
}
}
public class Program44 {
public static void main(String[] args) {
Scanner p = new Scanner(System.in);
System.out.println("please enter your id: ");
int a=p.nextInt();
System.out.println("please enter your age: ");
int b=p.nextInt();
paraconstructors obj=new paraconstructors(a,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
write a program that make a parameterized constructor (Java) (207)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment