0% found this document useful (0 votes)
7 views

Types of Constructor & Constructor Overloading Statements

oop notes constructor

Uploaded by

khanamazra82
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Types of Constructor & Constructor Overloading Statements

oop notes constructor

Uploaded by

khanamazra82
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Statements

Program Statement:
Write a Java program to implement a class Detailstudent that stores student details, such as first
name, last name, roll number, section, teacher, subject, and semester. The class should
demonstrate the use of parameterized and copy constructors. The copy constructor should allow
creating a new student object with the same details as an existing student, except for the subject
and teacher, which can be modified.
Program Statement:
Write a Java program for a class Classsum that demonstrates a parameterized constructor and a
copy constructor. The class should include methods to calculate and display the sum,
multiplication, and subtraction of two numbers. The copy constructor should allow creating a
new object by copying one of the values from an existing object while allowing
modification of the other.
Program Statement:
Write a Java program for a class Swap that demonstrates a parameterized constructor and a copy
constructor. The class should include a method to swap the values of two variables using
arithmetic operations. The copy constructor should allow creating a new object by copying one
of the values from an existing object, while allowing modification of the other value.

Default Constructor Program Statements:


1. Student Class
Program Statement: Write a Java program that demonstrates a default constructor in the Student
class. The constructor should initialize the student's name and age to default values.
2. Car Class
Program Statement: Create a Car class in Java that uses a default constructor to initialize the car
model and year to predefined default values.
3. Book Class
Program Statement: Implement a Book class in Java that uses a default constructor to set the title
and author of the book to default values.
4. Person Class
Program Statement: Write a Java program that demonstrates a default constructor in the Person
class. The default constructor should set the person's name and age to predefined values.
5. Mobile Class
Program Statement: Implement a Mobile class with a default constructor that initializes the
mobile's brand and model with default values.
6. Laptop Class
Program Statement: Write a Java program for the Laptop class where the default constructor
initializes the laptop brand and RAM size with default values.
7. Employee Class
Program Statement: Create an Employee class that uses a default constructor to initialize
employee name and salary with predefined default values.
8. Rectangle Class
Program Statement: Write a Java program that uses a default constructor to initialize a Rectangle
object with default length and width values.
9. Circle Class
Program Statement: Implement a Circle class in Java with a default constructor that initializes
the radius to a default value.
10. Pen Class
Program Statement: Write a Java program for a Pen class that uses a default constructor to
initialize the pen's color and price to default values.

Copy Constructor Program Statements:


1. Student Class
Program Statement: Write a Java program to demonstrate a copy constructor in the Student class.
The copy constructor should create a new Student object by copying the details from an existing
Student.
2. Car Class
Program Statement: Create a Car class that uses a copy constructor to initialize a new car object
by copying the details from another car object.
3. Book Class
Program Statement: Implement a Book class that uses a copy constructor to copy the book's
details (title and author) from an existing book object to a new one.
4. Person Class
Program Statement: Write a Java program that demonstrates the use of a copy constructor in the
Person class to copy name and age from one object to another.
5. Laptop Class
Program Statement: Create a Laptop class that uses a copy constructor to create a new laptop
object by copying details from an existing one.
6. Mobile Class
Program Statement: Implement a Mobile class in Java that demonstrates the use of a copy
constructor to copy the brand and model from an existing mobile object to a new one.

You might also like