Sign Up

Sign In

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Sorry, you do not have permission to ask a question, You must login to ask a question.

SIKSHAPATH Latest Articles

Solution Revealed: NPTEL Programming in Java Week 1 Assignment 2023

NPTEL Programming in Java Week 1 Quiz Answer

Are you enrolled in NPTEL’s programming in Java course and looking for help with the week 1 assignment?

Your solution is here in this article where I have provided probable answers for all 10 multiple choice questions.

NPTEL Programming in Java Week 1 Assignment Answer

Q1. What is the incorrect statement about bytecode?

Answer: c. Bytecode is not portable and it needs to be compiled separately for each platform.

1000+ students have already discovered the power of instant notifications – don’t be the last to join in Telegram Channel.


Q2. Consider the following program

public class Test
public static void main (String [] args) {

/ * * * * *** boolean b = false; *******/ / /n1
String b = "false";
switch (b) { / / n2
case "False":
System . out . printIn ("a") ;
    }
  }
}

What is the output of the above code?

Answer: d. Print nothing


Q3. Which one of the following is not a primitive datatype?

Answer: c. class


Q4. Which of the following is not a keyword in java?

Answer: c. integer

d. extend


Q5. Consider the following program.

public class Test
public static void main (String [] args) {

int a = 5;
a +=6;
switch (a-1) {

case 5: System. out . print ("10") ; break;
case 10: System. out. print ("15") ;
System.out.print ( ((a%2 ==0) ? "-even-" : "-odd-") ) ;
default: System.out.print (a%2) ; }

      }
}

Answer: b. 15-odd-1


Q6. Why does the error “javac is not recognized as an internal or external command” occur?

Answer: a. Path is not set for java


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

public class Question{
public static void main (String args [] ) {
char nptel []={'1' , '2' , '3', '4', '5' , '6'};
System.out.print(
___________);
  }
}

In the following, some options are given. You have to choose the correct option(s) for the
argument in System. out.print() function to print the value 102.

Answer: a. nptel[nptel.length-2] + nptel[0]

b. nptel[0] + nptel [nptel.length-2]


Q8. Which of the following concept that Java doesn’t support?

Answer: c. goto


Q9. The subsystem of JVM that is used to load class files is known as ________.

Answer: a. Classloader


Q10. What is the value of total after executing the following code snippet?

int mark = 5;
int grace = 2;
int total = mark + (mark > 6 ? ++grace : --grace);

Answer: a. 6


NPTEL Java Assignment Programming Answers

  1. Complete the code segment to help Ragav , find the highest mark and average mark secured by him in “s” number of subjects.
   int max=arr[0];
   int sum=0;
   
   for(i=0;i<arr.length;i++)
   {
     if (max<arr[i])
       max=arr[i];
     sum=sum+arr[i];
   }
   result=max;
   mark_avg= sum/s;
   
   System.out.println(result);
   System.out.print(mark_avg);

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

      int even =0;
      for(int i=1;i<=n;i++ )
      {
        if (even%3==0)
          sum+=even;
        even+=2;
      }
      System.out.print(sum);

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

      if(radius <=0)
        System.out.print(" please enter non zero positive number ");
      else
      {
        System.out.println(2*Math.PI*radius);
        System.out.print(Math.PI*radius*radius);
      }  

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

       int num=n;
       int sum=0;
       while(num>0)
       {
         int r=num%10;
         sum+=r*r*r;
         num/=10;
       }
       if (sum==n )
         result=1;
      
      System.out.print(result);
      

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

        if(x>y && x>z) 
        {
          
            result=x;
        }
        else if(y>x && y>z)
        {
            result=y;
        }
        else
          result=z;
        System.out.print(result);

TELEGRAM FOR NOTIFICATIONClick Here
Follow on Google News (in one click)Click Here

Disclaimer: I would like to offer these answers as a reference tool to assist students in their studies. It is important to note that Sikshapath cannot guarantee the accuracy of these answers and we strongly encourage students to complete their assignments independently. We hope that this reference material will be beneficial in supplementing the learning process.


Also Read:

NPTEL Java Week 2 Assignment Answers

Related Posts

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
100% Free SEO Tools - Tool Kits PRO