private Constructor() {
// body of the constructor
}
class Tutorialweb {
String website;
// public constructor
public Tutorialweb() {
website = "Softhunt.net";
}
}
class Main {
public static void main(String[] args) {
// object is created in another class
Tutorialweb obj = new Tutorialweb();
System.out.println("Tutorial website name = " + obj.website);
}
}
class Company {
String name;
// public constructor
public Company() {
name = "Programiz";
}
}
class Main {
public static void main(String[] args) {
// object is created in another class
Company obj = new Company();
System.out.println("Company name = " + obj.name);
}
}