[July-Dec] NPTEL Programming In Java Assignment 1 Answers 2022

In this post, We have provided answers of NPTEL Programming in Java Assignment 1. We provided answers here only for reference. Plz, do your assignment at your own knowledge.

NPTEL Registration Steps [July – Dec 2022]
NPTEL Exam Pattern Tips & Top Tricks [2022]
NPTEL Exam Result 2022 | NPTEL Swayam Result Download

NPTEL Programming In Java Assignment 1 Answers 2022 [July-Dec]

1. Consider the following program.

What will be the output of the program if it is executed?

a. 15
b. 12
C. 14
d. 10


2. Following is a piece of code where some parts of a statement is missing:

a. nptel[nptel.length-2] + nptel[0]
b. nptel[O] + nptel[nptel.length-2]
c. +nptel[nptel.length-2] + nptel[0]
d. +nptel[0] + nptel[nptel.length-2]


3. Consider the following program.

What will be the output of the progran if it is executed?

a. Print the value of N!
b. Print the value of NN+1)/2
c. Print the value of 1x3x5x.. xN
d. Print the value of 1!x2!x3!x…xN!


4. Which of the following can be used for a variable name in Java?

a. byte
b. throw
c. this
d. extend


5. Consider the following program.

What will be the output of the program if it is executed? Let N=10

a. 5
b. 20
C. 8
d. 10


6. A platform is the hardware or software environment in which a program runs. Which of the following is/are Java platform component(s)?

b. Java Virtual Machine
c. Java Application Programming Interface (API)
d. HotJava

ANSWER:- b, c

7. What is the value returned by the method f() defined below ? public static int f (int x, int y) {return (x>y) ? y: x;}

a. The sum of x and y that is, x + y.
b. The difference of x and y that is, x – y.
c. a. The maxinmum ofx and y that is, the larger value of x and y.
d. The minimum ofx and y that is, the smaller value of x and y.

ANSWER:- For Answer Click Here

8. A Java file with extension ‘.class’ contains

a. Java source code
b. HTML tags
c. Java Byte code
d. A program file written in Java programming language


9. Which of the following is used to find and fix bugs in the Java programs?

a. VM
b. JRE
d. JDB


10. Consider the following   program.

What will be the output of the program if it is executed?

a. Print first six even numbers.
b. Print first six odd numbers.
C. Print first five even numbers.
d. Print first six Fibonacci numbers


Programming In Java Week 1 Programming Assignment Answers

Q1. Complete the code segment to find the perimeter and area of a circle given a value of radius.

You should use Math.PI constant in your program. If radius is zero or less than zero then print ” please enter non zero positive number “


//Calculate the perimeter 
perimeter = 2 * Math.PI * radius;
System.out.println (perimeter);

//Calculate the area
area = Math.PI * radius * radius;

Q2. Complete the code segment to find the largest among three numbers x,y, and z. You should use if-then-else construct in Java.


//Use if...else ladder to find the largest among 3 numbers and store the largest number in a variable called result.
if (x > y && x > z)
  result = x;
  else if (y > z)
   result = y;
  result= z;

Q3. Consider First n even numbers starting from zero(0). Complete the code segment to calculate sum of  all the numbers divisible by 3 from 0 to n. Print the sum.


for (int i = 0; i < (n*2)-1; i++)
  if (i%2==0){
    sum = sum + i;

sum = sum/3;

Q4. Complete the code segment to check whether the number is an Armstrong number or not.


//Use while loop check the number is Armstrong or not.
//store the output(1 or 0) in result variable.

int temp, digits=0, last=0, sum=0;
  temp = temp/10;
temp = n;
while (temp>0)
  last = temp % 10;
  sum += (Math.pow(last, digits));
  temp = temp/10;
  result = 1;
  result = 0;

Q5. Complete the code segment to help Ragav , find the highest mark and average mark secured by him in “s” number of subjects.


//Initialize maximum element as first element of the array.  
   //Traverse array elements to get the current max.
   //Store the highest mark in the variable result.
   //Store average mark in avgMarks.
int sum = arr[0];
result = arr[0];
for (i=1; i<s; i++)
  if (result < arr[i])
    result = arr[i];
  sum = sum + arr[i];

mark_avg = sum / s;

For More NPTEL Answers:- CLICK HERE

Join Our Telegram:- CLICK HERE

About Programming In Java

With the growth of Information and Communication Technology, there is a need to develop large and complex software. Further, those software should be platform independent, Internet enabled, easy to modify, secure, and robust. To meet this requirement object-oriented paradigm has been developed and based on this paradigm the Java programming language emerges as the best programming environment. Now, Java programming language is being used for mobile programming, Internet programming, and many other applications compatible to distributed systems. This course aims to cover the essential topics of Java programming so that the participants can improve their skills to cope with the current demand of IT industries and solve many problems in their own filed of studies. 


  • Week 1  :  Overview of Object-Oriented Programming and Java
  • Week 2  :  Java Programming Elements
  • Week 3  :  Input-Output Handling in Java
  • Week 4  :  Encapsulation
  • Week 5  :  Inheritance
  • Week 6  :  Exception Handling 
  • Week 7  :  Multithreaded Programming 
  • Week 8  :  Java Applets and Servlets 
  • Week 9  :  Java Swing and Abstract Windowing Toolkit (AWT)
  • Week 10 : Networking with Java
  • Week 11:  Java Object Database Connectivity (ODBC)
  • Week 12:  Interface and Packages for Software Development


Average assignment score = 25% of average of best 8 assignments out of the total 12 assignments given in the course.
Exam score = 75% of the proctored certification exam score out of 100

Final score = Average assignment score + Exam score

YOU WILL BE ELIGIBLE FOR A CERTIFICATE ONLY IF AVERAGE ASSIGNMENT SCORE >=10/25 AND EXAM SCORE >= 30/75. If one of the 2 criteria is not met, you will not get the certificate even if the Final score >= 40/100.

5 thoughts on “[July-Dec] NPTEL Programming In Java Assignment 1 Answers 2022”

Leave a Comment