10/14/24, 8:13 AM Programming in Java - - Unit 7 - Week 4 :
eswardilleswar8888@[Link]
([Link]
([Link]
NPTEL ([Link] » Programming in Java (course)
Course outline Week 04: Assignment 04
The due date for submitting this assignment has passed.
About NPTEL () Due on 2024-08-21, 23:59 IST.
How does an NPTEL
online course work?
Assignment submitted on 2024-08-21, 05:37 IST
() 1) Which of these access specifiers must be used for main() method? 1 point
Week 0 : () a. private
b. public
Week 1 : () c. protected
d. default
Week 2 : ()
Yes, the answer is correct.
[Link] 1/7
10/14/24, 8:13 AM Programming in Java - - Unit 7 - Week 4 :
Score: 1
Week 3 : () Accepted Answers:
b. public
Week 4 : ()
2) What is the output of the below Java Code Snippet with protected access modifier? 1 point
Lecture 16 :
Demonstration-VII
(unit?
// [Link] ------------------
unit=42&lesson=43)
package nptel1;
Lecture 17 : Packages-I
(unit?
public class Teacher {
unit=42&lesson=44) protected void showMarks() {
Lecture 18 : Packages- [Link]("100 Marks");
II (unit?
}
unit=42&lesson=45)
}
Lecture 19 :
Demonstration-VIII
(unit?
// [Link] ------------------
unit=42&lesson=46)
package nptel2;
Lecture 20 : Interface-I
(unit? import nptel1.*;
unit=42&lesson=47)
public class Student extends Teacher {
Feedback Form (unit? void show() {
unit=42&lesson=48)
showMarks();
Week 04 :
}
Programming
Assignment 1 public static void main(String[] args) {
(/noc24_cs105/progassi
Student st1 = new Student();
gnment?name=371)
[Link]();
Week 04 :
Programming }
Assignment 2 }
(/noc24_cs105/progassi
gnment?name=372)
a. 100 marks
[Link] 2/7
10/14/24, 8:13 AM Programming in Java - - Unit 7 - Week 4 :
Week 04 : b. No output
Programming
c. Compiler error
Assignment 3
(/noc24_cs105/progassi d. None of the above
gnment?name=373) Yes, the answer is correct.
Score: 1
Week 04 :
Accepted Answers:
Programming
a. 100 marks
Assignment 4
(/noc24_cs105/progassi 3) What is the process by which we can control what parts of a program can access the members of a class? 1 point
gnment?name=374)
a. Polymorphism
Week 04 :
Programming b. Augmentation
Assignment 5 c. Encapsulation
(/noc24_cs105/progassi
d. Recursion
gnment?name=375)
Yes, the answer is correct.
Quiz: Week 04: Score: 1
Assignment 04 Accepted Answers:
(assessment? c. Encapsulation
name=392)
Week 04 : Assignment 4) Consider the 2 programs: 1 point
Solution (unit?
unit=42&lesson=435)
// [Link] ------------------
Week 5 : ()
public class Main1{
Week 6 : () public static void main(String args[]){
int number = 10;
Week 7 : ()
[Link](number++ + ++number);
Week 8 : () }
}
Week 9 : ()
Week 10 : ()
// [Link] ------------------
[Link] 3/7
10/14/24, 8:13 AM Programming in Java - - Unit 7 - Week 4 :
public class Main2{
Week 11 : ()
public static void main(String args[]){
Week 12 : () int number = 10;
[Link](++number + number++);
Books ()
}
Text Transcripts () }
a. Both pre-increment and post-increment operators becomes pre-increment during print.
b. Both pre-increment and post-increment operators becomes post-increment during print.
c. Both Main1 and Main2 classes give the same output.
d. Pre-increment and post-increment operators don’t work during print.
Yes, the answer is correct.
Score: 1
Accepted Answers:
c. Both Main1 and Main2 classes give the same output.
5) Which is the least restrictive access modifier in Java? 1 point
a. public
b. private
c. protected
d. default
Yes, the answer is correct.
Score: 1
Accepted Answers:
a. public
6) Choose the correct syntax of a Java Package below. 1 point
a. package PACKAGE_NAME;
b. package PACKAGE_NAME.*;
c. pkg PACKAGE_NAME;
[Link] 4/7
10/14/24, 8:13 AM Programming in Java - - Unit 7 - Week 4 :
d. pkg PACKAGE_NAME.*;
Yes, the answer is correct.
Score: 1
Accepted Answers:
a. package PACKAGE_NAME;
7) What is the default package in Java? 1 point
a. It is a package that contains all built-in classes.
b. It is a package that needs to be defined as default.
c. It is a package that does not have a name.
d. It is a package used for importing external libraries.
Yes, the answer is correct.
Score: 1
Accepted Answers:
c. It is a package that does not have a name.
8) A package is a collection of: 1 point
a. classes
b. interfaces
c. editing tools
d. classes and interfaces
Yes, the answer is correct.
Score: 1
Accepted Answers:
d. classes and interfaces
9) In Java, can a subclass in a different package access a superclass’s protected method? 1 point
a. Yes, without any restrictions.
b. Yes, but only if they are in the same package.
c. No, protected methods are not accessible by subclasses.
d. No, protected methods are only accessible within the same class.
[Link] 5/7
10/14/24, 8:13 AM Programming in Java - - Unit 7 - Week 4 :
No, the answer is incorrect.
Score: 0
Accepted Answers:
b. Yes, but only if they are in the same package.
10) Consider the program given below. What will be the output if the program is executed? 0 points
// [Link] ------------------
public class Main1{
public static void main(String args[]){
int number = 10;
[Link](number++ + ++number);
}
}
// [Link] ------------------
public class Main2{
public static void main(String args[]){
int number = 10;
[Link](++number + number++);
}
}
a. It will give compile-time error
b. It will give run-time error
c. 1.0
d. 3.14
Yes, the answer is correct.
[Link] 6/7
10/14/24, 8:13 AM Programming in Java - - Unit 7 - Week 4 :
Score: 0
Accepted Answers:
a. It will give compile-time error
[Link] 7/7