Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
24 views

Programming in Java - - Unit 7 - Week 4 _

The document outlines the details of Week 4 assignments for the NPTEL Programming in Java course, including submission deadlines and questions related to Java access specifiers, output of code snippets, and package definitions. It includes correct answers and scores for various questions, indicating the assessment of the student's understanding of Java concepts. The document also references specific lectures and assignments within the course structure.

Uploaded by

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

Programming in Java - - Unit 7 - Week 4 _

The document outlines the details of Week 4 assignments for the NPTEL Programming in Java course, including submission deadlines and questions related to Java access specifiers, output of code snippets, and package definitions. It includes correct answers and scores for various questions, indicating the assessment of the student's understanding of Java concepts. The document also references specific lectures and assignments within the course structure.

Uploaded by

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

13/11/2024, 15:26 Programming in Java - - Unit 7 - Week 4 :

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

vinamrasrivastava112@gmail.com 

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

Course Week 04: Assignment 04


outline The due date for submitting this assignment has passed.
Due on 2024-08-21, 23:59 IST.
About
NPTEL ()
Assignment submitted on 2024-08-21, 22:15 IST
How does an 1) Which of these access specifiers must be used for main() method? 1 point
NPTEL
online a. private
course b. public
work? ()
c. protected

Week 0 : () d. default
Yes, the answer is correct.
Week 1 : () Score: 1
Accepted Answers:
b. public
Week 2 : ()

Week 3 : () 2) What is the output of the below Java Code Snippet with protected access modifier? 1 point

Week 4 : ()
// Teacher.java ------------------
Lecture 16 :
package nptel1;
Demonstration
-VII (unit? public class Teacher {
unit=42&lesso
protected void showMarks() {
n=43)
System.out.println("100 Marks");
Lecture 17 :
Packages-I }
(unit? }
unit=42&lesso
n=44)

// Student.java ------------------

https://onlinecourses.nptel.ac.in/noc24_cs105/unit?unit=42&assessment=392 1/5
13/11/2024, 15:26 Programming in Java - - Unit 7 - Week 4 :

Lecture 18 : package nptel2;


Packages-II import nptel1.*;
(unit?
unit=42&lesso public class Student extends Teacher {
n=45) void show() {
Lecture 19 : showMarks();
Demonstration
}
-VIII (unit?
unit=42&lesso public static void main(String[] args) {
n=46)
Student st1 = new Student();
Lecture 20 :
st1.show();
Interface-I
(unit? }
unit=42&lesso }
n=47)

Feedback a. 100 marks


Form (unit?
b. No output
unit=42&lesso
n=48) c. Compiler error
d. None of the above
Week 04 :
Programming Yes, the answer is correct.
Assignment 1 Score: 1
(/noc24_cs105 Accepted Answers:
/progassignme a. 100 marks
nt?name=371)
3) What is the process by which we can control what parts of a program can access 1 point
Week 04 : the members of a class?
Programming
Assignment 2 a. Polymorphism
(/noc24_cs105
b. Augmentation
/progassignme
nt?name=372) c. Encapsulation
d. Recursion
Week 04 :
Programming Yes, the answer is correct.
Assignment 3 Score: 1
(/noc24_cs105 Accepted Answers:
/progassignme c. Encapsulation
nt?name=373)
4) Consider the 2 programs: 1 point
Week 04 :
Programming
Assignment 4
(/noc24_cs105 // Main1.java ------------------
/progassignme
public class Main1{
nt?name=374)
public static void main(String args[]){
Week 04 :
Programming int number = 10;
Assignment 5 System.out.println(number++ + ++number);
(/noc24_cs105
/progassignme }
nt?name=375) }
Quiz: Week
04:

https://onlinecourses.nptel.ac.in/noc24_cs105/unit?unit=42&assessment=392 2/5
13/11/2024, 15:26 Programming in Java - - Unit 7 - Week 4 :

Assignment // Main2.java ------------------


04
(assessment? public class Main2{
name=392) public static void main(String args[]){
Week 04 : int number = 10;
Assignment
System.out.println(++number + number++);
Solution (unit?
unit=42&lesso }
n=435)
}
Week 5 : ()
a. Both pre-increment and post-increment operators becomes pre-increment during print.
Week 6 : () b. Both pre-increment and post-increment operators becomes post-increment during
print.
Week 7 : () c. Both Main1 and Main2 classes give the same output.
d. Pre-increment and post-increment operators don’t work during print.
Week 8 : ()
Yes, the answer is correct.
Score: 1
Week 9 : ()
Accepted Answers:
c. Both Main1 and Main2 classes give the same output.
Week 10 : ()
5) Which is the least restrictive access modifier in Java? 1 point
Week 11 : ()
a. public
Week 12 : () b. private
c. protected
Books () d. default

Text Yes, the answer is correct.


Score: 1
Transcripts
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;
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.

https://onlinecourses.nptel.ac.in/noc24_cs105/unit?unit=42&assessment=392 3/5
13/11/2024, 15:26 Programming in Java - - Unit 7 - Week 4 :

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 0 points


method?

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.

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 0 points
executed?

// Main1.java ------------------
public class Main1{

public static void main(String args[]){


int number = 10;
System.out.println(number++ + ++number);
}
}

// Main2.java ------------------
public class Main2{
public static void main(String args[]){
int number = 10;
System.out.println(++number + number++);

https://onlinecourses.nptel.ac.in/noc24_cs105/unit?unit=42&assessment=392 4/5
13/11/2024, 15:26 Programming in Java - - Unit 7 - Week 4 :

a. It will give compile-time error


b. It will give run-time error
c. 1.0
d. 3.14

No, the answer is incorrect.


Score: 0
Accepted Answers:
a. It will give compile-time error

https://onlinecourses.nptel.ac.in/noc24_cs105/unit?unit=42&assessment=392 5/5

You might also like