0% found this document useful (0 votes)
41 views1 page

Public Class Public Public Public Int Public Static Void New New New Public

The document defines a Persoana class with three constructors. The first constructor sets the default first name to "Stelian" and prints messages. The second constructor sets the first name and age based on String and int parameters passed to it, then prints messages. The third constructor calls the second constructor, passing the String parameter and default age of 25, implicitly setting the object's first name and age.

Uploaded by

Dragu Stelian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views1 page

Public Class Public Public Public Int Public Static Void New New New Public

The document defines a Persoana class with three constructors. The first constructor sets the default first name to "Stelian" and prints messages. The second constructor sets the first name and age based on String and int parameters passed to it, then prints messages. The third constructor calls the second constructor, passing the String parameter and default age of 25, implicitly setting the object's first name and age.

Uploaded by

Dragu Stelian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 1

package persoana;

public class Persoana


{
public String firstname = "Stelian";
public String secondname;
public int age;
public static void main(String[] args)
{
Persoana obj;
obj = new Persoana();
obj = new Persoana("Mircea", 34);
obj = new Persoana("Stelian");
}
public Persoana()
{
firstname = "Stelian";
System.out.println("Apel primul constructor!");
System.out.println("My name is: "+firstname);
}
public Persoana(String nume, int varsta)
{
firstname = nume;
age = varsta;
System.out.println("Apel al doilea constructor!");
System.out.println("My name is: "+firstname);
System.out.println("My age is: "+age);
}
public Persoana(String n)
{
this(n, 25);
}
}

You might also like