package com.company;
class constructors
{
private int id;
private int age;
public constructors() //default constructor
{
id=4718;
age=18;
}
public void set ()
{
System.out.println("your age is: "+age);
System.out.println("your roll no is: "+id);
}
}
public class Program43 {
public static void main(String[] args) {
constructors obj=new constructors();
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 default constructor (Java) (206)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment