Week 3

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

X

abhisheklodhi2842004@gmail.com

(https://swayam.gov.in)

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

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 outline Assignment submitted on 2024-02-03, 23:49 IST


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

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

a. Call constructor of friend class


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

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

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

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

Quiz: Week 03 :
Assignment 03
(assessment?
name=296)

Assignment 3
Solution (unit?
unit=34&lesson=
41)

Week 3 a. 0
Feedback Form b. 1
(unit?
unit=34&lesson=
c. 2
40) d. Compilation Error

Yes, the answer is correct.


Week 4 : () Score: 1
Accepted Answers:
Week 5 : () c. 2

Week 6 : () 4) 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.
Week 7 : ()
b. No, static methods cannot be overridden because they belong to the class, not the object.
Week 8 : () 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.
Week 9 : ()
Yes, the answer is correct.
Score: 1
Week 10 : () Accepted Answers:
b. No, static methods cannot be overridden because they belong to the class, not the object.
Week 11 : ()
5) What is the output of the following Java program? 0 points
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

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.”

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.

You might also like