0% found this document useful (0 votes)
55 views5 pages

Kartik 3pdf

The document discusses a Java programming assignment related to inheritance and constructors. It provides example code and questions to test understanding of concepts like calling parent constructors, overriding methods, hiding methods, and differences between static and instance methods.

Uploaded by

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

Kartik 3pdf

The document discusses a Java programming assignment related to inheritance and constructors. It provides example code and questions to test understanding of concepts like calling parent constructors, overriding methods, hiding methods, and differences between static and instance methods.

Uploaded by

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

5/21/24, 9:50 AM Programming In Java - - Unit 6 - Week 3 :

(https://swayam.gov.in) (https://swayam.gov.in/nc_details/NPTEL)

[email protected]

NPTEL (https://swayam.gov.in/explorer?ncCode=NPTEL) » Programming In Java (course)

If already
registered, click
to check your
Week 03 : Assignment 03
payment status The due date for submitting this assignment has passed.
Due on 2024-02-14, 23:59 IST.

Course Assignment submitted on 2024-02-04, 13:17 IST


outline
1) Which of the following statement is true regarding the order of execution of 1 point
constructors in an inheritance hierarchy?
About
NPTEL () a. Base class constructor will be called followed by the derived class constructor.
b. Derived class constructor will be called followed by the base class constructor.
How does an
c. Only Base class constructor will be called.
NPTEL
online d. Only derived class constructor will be called.
course Yes, the answer is correct.
work? () Score: 1
Accepted Answers:
Week 0 : () a. Base class constructor will be called followed by the derived class constructor.

Week 1 : () 2) The super() method is used to: 1 point

Week 2 : () a. Call constructor of friend class


b. Is a declared method
Week 3 : () c. Call constructor of the parent class
d. Call constructor
Lecture 11 :
Java Static Yes, the answer is correct.
Scope Rule Score: 1
(unit? Accepted Answers:
unit=34&lesso c. Call constructor of the parent class
n=35)
3) What will be the output of the following Java program? 1 point
Lecture 12 :
Demonstration

https://onlinecourses.nptel.ac.in/noc24_cs43/unit?unit=34&assessment=296 1/5
5/21/24, 9:50 AM Programming In Java - - Unit 6 - Week 3 :

-V (unit?
unit=34&lesso
n=36)

Lecture 13 :
Inheritance
(unit?
unit=34&lesso
n=37)

Lecture 14 :
Demonstration
-VI (unit?
unit=34&lesso
n=38)

Lecture 15 :
Information
Hiding (unit?
unit=34&lesso
n=39)

Quiz: Week
03 :
Assignment
a. 0
03
(assessment? b. 1
name=296) c. 2
Assignment 3 d. Compilation Error
Solution (unit?
Yes, the answer is correct.
unit=34&lesso Score: 1
n=41)
Accepted Answers:
Week 3 c. 2
Feedback
4) In Java, is it possible to override a static method? 1 point
Form (unit?
unit=34&lesso
a. Yes, we can override a static method just like we do with instance methods.
n=40)
b. No, static methods cannot be overridden because they belong to the class, not the
Week 4 : () object.
c. It depends on whether the static method is declared as final or not.
Week 5 : () d. It depends on the access modifier of the static method.

Week 6 : () Yes, the answer is correct.


Score: 1
Accepted Answers:
Week 7 : () b. No, static methods cannot be overridden because they belong to the class, not the object.

Week 8 : ()
5) What is the output of the following Java program? 0 points

Week 9 : ()

Week 10 : ()

Week 11 : ()

https://onlinecourses.nptel.ac.in/noc24_cs43/unit?unit=34&assessment=296 2/5
5/21/24, 9:50 AM Programming In Java - - Unit 6 - Week 3 :

Week 12 : ()

DOWNLOAD
VIDEOS ()

Books ()

Text
Transcripts ()

Problem
Solving
Session -
Jan 2024 ()
a. "The vehicle moves"
b. "The car moves"
c. The code does not compile
d. None of the above

Yes, the answer is correct.


Score: 0
Accepted Answers:
b. "The car moves"

6) What is the output of the below Java program with inheritance? 1 point

a. Sweet=$10 Sugar=$20
b. Sweet=$10 Sugar=$10
c. Sweet=$20 Sugar=$20
d. Compiler error

Yes, the answer is correct.


Score: 1
Accepted Answers:
a. Sweet=$10 Sugar=$20

https://onlinecourses.nptel.ac.in/noc24_cs43/unit?unit=34&assessment=296 3/5
5/21/24, 9:50 AM Programming In Java - - Unit 6 - Week 3 :

7) What is the purpose of method hiding in Java inheritance? 1 point

a. To prevent a subclass from inheriting methods


b. To override superclass methods with new implementations
c. To expose private methods of the superclass
d. To define methods with the same name in both the superclass and subclass
Yes, the answer is correct.
Score: 1
Accepted Answers:
d. To define methods with the same name in both the superclass and subclass

8) What is the output of the following Java program? 1 point

a. "parent from parent"


b. "child from child"
c. "parent from child"
d. "child from parent"

Yes, the answer is correct.


Score: 1
Accepted Answers:
c. "parent from child"

9) Can a class be marked as both “final” and “abstract” in Java? 1 point

a. Yes, but only if it has no methods.


b. Yes, a class can be marked as both “final” and “abstract.”
c. No, a class cannot be both “final” and “abstract.”
d. Yes, but only if it is marked as “protected.”

Y h i

https://onlinecourses.nptel.ac.in/noc24_cs43/unit?unit=34&assessment=296 4/5
5/21/24, 9:50 AM Programming In Java - - Unit 6 - Week 3 :

Yes, the answer is correct.


Score: 1
Accepted Answers:
c. No, a class cannot be both “final” and “abstract.”

10) In Java, is it possible to override a static method? 1 point

a. Yes, we can override a static method just like we do with instance methods.
b. No, static methods cannot be overridden because they belong to the class, not the
object.
c. It depends on whether the static method is declared as final or not.
d. It depends on the access modifier of the static method.

Yes, the answer is correct.


Score: 1
Accepted Answers:
b. No, static methods cannot be overridden because they belong to the class, not the object.

https://onlinecourses.nptel.ac.in/noc24_cs43/unit?unit=34&assessment=296 5/5

You might also like