0% found this document useful (0 votes)
10 views

Programming in Java - - Unit 4 - Week 1 _

The document outlines the first week of the Programming in Java course on NPTEL, detailing assignments and quiz questions with correct answers. It includes various programming concepts such as comments, output of code snippets, debugging tools, and the role of the main method in Java. The assignments are due on specific dates, and the document records submission times and scores for completed assignments.

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)
10 views

Programming in Java - - Unit 4 - Week 1 _

The document outlines the first week of the Programming in Java course on NPTEL, detailing assignments and quiz questions with correct answers. It includes various programming concepts such as comments, output of code snippets, debugging tools, and the role of the main method in Java. The assignments are due on specific dates, and the document records submission times and scores for completed assignments.

Uploaded by

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

13/11/2024, 15:25 Programming in Java - - Unit 4 - Week 1 :

(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)

Course Week 01: Assignment 01


outline The due date for submitting this assignment has passed.
Due on 2024-08-07, 23:59 IST.
About
NPTEL ()
Assignment submitted on 2024-08-06, 22:26 IST
How does an 1) Which of the following is not a valid comment in Java? 1 point
NPTEL
online a. /** comment */
course b. /* comment */
work? ()
c. /* comment /

Week 0 : () d. // comment
Yes, the answer is correct.
Week 1 : () Score: 1
Accepted Answers:
Lecture 01 : c. /* comment /
Introduction
(unit? 2) What is the output of the following code? 1 point
unit=18&lesso
n=19)
public class Main {
Lecture 02 :
public static void main(String[] args) {
Java
Programming String str1 = "NPTEL";
Steps (unit?
String str2 = "java";
unit=18&lesso
n=20) int a = 20;

Lecture 03 :
int b = 24;
Java Tools and System.out.println(str1 + a + b); // Statement 1
Resources
(unit?
unit=18&lesso System.out.println(a + b + str2); // Statement 2
n=21)
}

https://onlinecourses.nptel.ac.in/noc24_cs105/unit?unit=18&assessment=388 1/4
13/11/2024, 15:25 Programming in Java - - Unit 4 - Week 1 :

Lecture 04 : }
Demonstration
-I (unit?
unit=18&lesso a. NPTEL2024
n=22)
44java
Lecture 05 : b. NPTEL44
Java Applet 44java
Programming
c. NPTEL2024
(unit?
unit=18&lesso 2024java
n=23) d. NPTEL44
2024java
Feedback
Form (unit? Yes, the answer is correct.
unit=18&lesso Score: 1
n=24) Accepted Answers:
a. NPTEL2024
Week 01 :
44java
Programming
Assignment 1 3) Which of the following is used to find and fix bugs in the Java programs? 1 point
(/noc24_cs105
/progassignme a. JVM
nt?name=361)
b. JRE
Week 01 : c. JDK
Programming
d. JDB
Assignment 2
(/noc24_cs105 Yes, the answer is correct.
/progassignme Score: 1
nt?name=362) Accepted Answers:
d. JDB
Week 01 :
Programming
4) What is the value returned by the method f() defined below ? 1 point
Assignment 3
(/noc24_cs105
/progassignme public static int f(int x, int y){return (x>y) ? y : x;}
nt?name=363)

Week 01 :
Programming a. The sum of x and y, that is, x + y.
Assignment 4 b. The difference of x and y, that is, x - y.
(/noc24_cs105
c. The maximum of x and y, that is, the larger value of x and y.
/progassignme
nt?name=364) d. The minimum of x and y, that is, the smaller value of x and y.

Week 01 : Yes, the answer is correct.


Score: 1
Programming
Assignment 5
Accepted Answers:
(/noc24_cs105
d. The minimum of x and y, that is, the smaller value of x and y.
/progassignme
nt?name=365) 5) Consider the following program. What will be the output of the program if it is 1 point
executed?
Quiz: Week
01:
Assignment public class Question {
01 public static void main(String args[]) {
(assessment?
name=388) int f = 0, g = 1;

https://onlinecourses.nptel.ac.in/noc24_cs105/unit?unit=18&assessment=388 2/4
13/11/2024, 15:25 Programming in Java - - Unit 4 - Week 1 :

Week 01 : for (int i = 0; i <= 5; i++) {


Assignment System.out.println(f);
Solution (unit?
unit=18&lesso f = f + g;
n=430) g = f - g;

Week 2 : () }
}
Week 3 : ()
}

Week 4 : ()

a. Print first six even numbers.


Week 5 : ()
b. Print first six odd numbers.
Week 6 : () c. Print first six prime numbers.
d. Print first six Fibonacci numbers.
Week 7 : ()
Yes, the answer is correct.
Score: 1
Week 8 : () Accepted Answers:
d. Print first six Fibonacci numbers.
Week 9 : ()
6) Which program is used to compile Java source code into bytecode? 1 point
Week 10 : ()
a. javap

Week 11 : () b. javac
c. java
Week 12 : () d. javad

Yes, the answer is correct.


Books () Score: 1
Accepted Answers:
Text b. javac
Transcripts
() 7) Consider the following program. 1 point

public class Question {


public static void main(String[] args) {
int x = 5;
x *= (2 + 8);

System.out.println(x);
}
}

a. 50
b. 10
c. Compiler error
d. 5

https://onlinecourses.nptel.ac.in/noc24_cs105/unit?unit=18&assessment=388 3/4
13/11/2024, 15:25 Programming in Java - - Unit 4 - Week 1 :

Yes, the answer is correct.


Score: 1
Accepted Answers:
a. 50

8) What is the incorrect statement about bytecode? 1 point

a. Java when compiles the source code, it converts it to bytecode.


b. JVM (Java Virtual Machine) is an interpreter of bytecode.
c. Bytecode is not portable and it needs to be compiled separately for each platform.
d. JVM offers a protected environment which helps in enhanced safety for the system.

Yes, the answer is correct.


Score: 1
Accepted Answers:
c. Bytecode is not portable and it needs to be compiled separately for each platform.

9) In Java, what is the role of the public static void main(String[] args) method? 1 point

a. Initialization method
b. Execution entry point
c. Constructor
d. Destructor

Yes, the answer is correct.


Score: 1
Accepted Answers:
b. Execution entry point

10) What is the purpose of the break statement in Java? 1 point

a. To terminate the program


b. To exit a loop or switch statement
c. To skip the next iteration of a loop
d. To return a value from a method

Yes, the answer is correct.


Score: 1
Accepted Answers:
b. To exit a loop or switch statement

https://onlinecourses.nptel.ac.in/noc24_cs105/unit?unit=18&assessment=388 4/4

You might also like