Fundamentals of Object Oriented Programming - - Unit 5 - Week 2 Solved Question
Fundamentals of Object Oriented Programming - - Unit 5 - Week 2 Solved Question
(https://swayam.gov.in) (https://swayam.gov.in/nc_details/NPTEL)
(course)
Click to register
for Certification
exam
Week 2: Assignment 2
(https://examform.nptel.ac.in/2025_01/exam_form/dashboard)
Assignment not submitted Due date: 2025-02-05, 23:59 IST.
If already 1) Which of the following best describes a class in object-oriented programming? 1 point
registered, click
to check your A block of code that defines functions only.
payment status A blueprint for creating objects, encapsulating data and methods.
A template for functions without data.
A data structure for storing primitive data types.
Course
outline 2) What happens when an object is created from a class in C++? 1 point
Classes and
4) In a Java program to define a class Circle with: 1 point
Objects in C++
(unit?
A constructor that initializes its radius.
unit=32&lesson A method getArea() to return the area of the circle.
=33)
Identify the correct syntax to create an object of this class.
Classes and
Objects in Java Circle c1 = new Circle();
and Solved Circle c1 = new Circle(radius);
problems (unit?
Circle c1 = Circle(radius);
unit=32&lesson
=34) Circle c1 = new Circle[radius];
Constructors in
C++: Default
and
Parameterized
(unit?
https://onlinecourses.nptel.ac.in/noc25_cs34/unit?unit=32&assessment=38 1/4
2/5/25, 5:51 PM Fundamentals of Object Oriented Programming - - Unit 5 - Week 2
Constructors in
C++: Copy
Constructor
(unit?
unit=32&lesson
=36)
Constructors in
Java: Default
and
Parameterized
(unit?
unit=32&lesson
=37) What is the output of this program?
Quiz: Week 2:
Assignment 2 Constructor called
(assessment? Display function
name=38) Destructor called
Constructor called
Display function
Constructor called
Inside createObject function
Destructor called
Before calling createObject
After calling createObject
https://onlinecourses.nptel.ac.in/noc25_cs34/unit?unit=32&assessment=38 2/4
2/5/25, 5:51 PM Fundamentals of Object Oriented Programming - - Unit 5 - Week 2
8) A class in C++ has multiple constructors. How does the compiler decide which 1 point
constructor
to use?
FileHandler(std::string filename);
FileHandler(char* filename);
FileHandler(const char filename[]);
All of the above
10) Analyze the following C++ code and identify the correct output: 1 point
15
8
Compilation error
Undefined behavior
You may submit any number of times before the due date. The final submission will be considered
for grading.
Submit Answers
https://onlinecourses.nptel.ac.in/noc25_cs34/unit?unit=32&assessment=38 3/4
2/5/25, 5:51 PM Fundamentals of Object Oriented Programming - - Unit 5 - Week 2
https://onlinecourses.nptel.ac.in/noc25_cs34/unit?unit=32&assessment=38 4/4