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

NPTEL Programming in Java Week 2 Assignment Answers 2023

NPTEL Programming in Java Week 2 Assignment Answers 2023

Excited for NPTEL’s Java programming week 2 quiz assignment answers?

Look no further! I’ve got you covered with probable answers for all 10 questions. Use these as a helpful guide in completing your assignment with confidence before the deadline.

NPTEL Programming in Java Week 2 Assignment Answers

Q1. Following is a program given for this question.

public class Question{
public static void main(String[] args) {
int[] x = {222, 210, 012);
for (int i = 0; i < x.length; i++) { 
System.out.print (x[i] + "");
    }
  }
}

What will be the output of the above program?

Answer: a. 22221010

1000+ subscribers getting help from instant notifications, Join us on telegram.


Q2. When an array is passed to a method, what value does the method receive?

Answer: a. Reference of the array.


Q3. Following is a program given for this question.

public class Main{
    public static void main(String args[]) {
     byte x = 28;
     x++;
     x++;
   System.out.print (x);
   }
}

What will be the output of the above program?

Answer: c. 30


Q4. How many bits are needed for float and double in Java, respectively?

Answer: a. 32 and 64


Q5. Which of the following is a valid automatic type conversion in Java?

Answer: d. int to long


Q6. Consider the following program and identify the output.

public class Question{
 static void main(String[] args) {
 short x = 10;
 x = x * 5;
 System.out.print(x);
 }
}

Answer: d. Compilation error


Q7. Which of the following is a valid declaration of an object of class say, Student?

Answer: b. Student obj = new Student();


Q8. What is the output of the following program?

public class Question{
public static void main(String[] args) {
int[] A = {0,1,2);
for (int i = 0; i < A.length; i++) {
A[i] A[(A[i] + 3) % A.length];
   }
   for (int i = 0; i < A.length; i++) { 
   System.out.print (A[i]);
  }
 }
}

Answer: c. 012


Q9. Consider the following piece of code.

public class Question{
public static void main(String[] args) { 
   String str = "anpotdelqjpava";
System.out.println(str.substring(1,3) +str.substring (4,5)+ str.substring(6,8));
 }
}

Which of the following option is the output of the above program?

Answer: d. nptel


Q10. What is the output of the following program?

public class Main{
  public void static main(String args[]) { 
char a = '3';
int b = 011;
System.out.println(a+b);
 }
}

Answer: d. Compilation error

Programming Answers to Java Assignment

Q1. Complete the code segment to call the method  print() of class School first and then call print() method of class Student.

School school = new School(); 
        Student student = new Student(); 
        
        school.print(); 
        student.print(); 

Q2.

    Printer p=new Printer();
    String s="Hi! I class SCHOOL.";
    String r="Hi! I am class STUDENT";
    p.print(s);
    p.print(r);

Q3.

void student()
    {
	
		print(this);
	}

Q4.

class Answer{
	
	Answer(){
		System.out.println("You got nothing.");
	}
	
	Answer(int marks, String type){
		
		this();		
		
		System.out.print("You got "+marks+" for an "+ type);
	}
}

Q5.

  System.out.print(nptel+space+java+space+nptel);

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

Disclaimer: These answers are intended only as reference material. No guarantee of accuracy is made. It is strongly recommended to complete the assignment independently.


Also Available:

NPTEL Programming in Java Week 1 Assignment Answers

NPTEL Programming In Java Week 3 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