NPTEL Programming In Java Assignment 2 Answers July 2022

NPTEL Programming In Java Assignment 2 Answers July 2022:- All the Answers are provided here to help the students as a reference, You must submit your assignment at your own knowledge

NPTEL Programming In Java Assignment 2 Answers [July 2022]

1. What is the output of the following program?

public class Main {
                   public static void main (String args[]) { 
                               char a = '8';
                                int b=010;
                                System.out .println (a+b) ; 
                   }
           }
  • a. 88
  • b. 8010
  • c. 64
  • d. 810
Answer:- c

2. Which of the following is generate API documentation in HTML format from Java source code?

a. javac
b. javadoc
c. javap
d. java

Answer:- b

Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW

NPTEL Programming In Java Assignment 2 Answers July 2022

3. Following is a program given for this question.

What will be the output of the above program?

a. javanptel
b. npteljava
c. janjavanptel
d. jannpteljava

Answer:- b

4. What will happen during the execution of the following code for the command line input?

Consider the following input on command line and select the options with the correct output(s). nput:

A: “jan java nptel”
B: 123

a. A: jannptel
javanptel1
nptelnptel
b. A:jan java nptel jan java nptel
c. B: 11
21
31
d. B: 1231

Answer:- b, c

5. Which of the following is/are TRUE about print) and println) methods?

a. print () prints in a single line only and multiple lines cannot be printed in any way.
b. print () prints and then appends a line break.
c. println () prints in a single line only and multiple lines cannot be printed.
d. println () prints and then appends a line break.

Answer:- d

6. What was the initial name of Java when it was first developed for embedded systems?

a. Greentalk
b. Oak
c. Java
d. Javac

Answer:- a

👇For Week 03 Assignment Answers👇

NPTEL Programming In Java Assignment 2 Answers July 2022

7. Which of the following is a valid declaration of an object of class, say Foo?

a. Foo obj = new Foo;
b. obj = new Foo();
c. Foo obj = new Fool;
d. new Foo obj;

Answer:- c

8. Following is a program given for this question.

What will be the output of the above program?

a. 0
b. 1
c. false
d. true

Answer:- For Answer Click Here

9. Which of the following can be used to take input from user during the execution of a program?

a. Using the string array provided as a parameter to the main method.
b. getText() method can be used to get user input from the command line.
c. Scanner class can be used by passing the predefined object System.in
d. Once the execution starts, there is no way to provide user input.

Answer:- c

10. What is the output of the following program?

a 14
b. 12
c. 15
d. 17

Answer:- d

Programming Assignment Answers

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

Code:-

Student st=new Student();
st.print();

School sch=new School();
sch.print();

Q2. Complete the code segment to call the method  print() of class given class Printer to print the following.
Code:-

Printer ptr=new Printer();
String s1="Hi! I am class STUDENT";
ptr.print(s1);
ptr.print();

Q3. Complete the code segment tocall print() method of class Question by creating a method named â€˜studentMethod()’.
Code:-


  public void studentMethod()
  {
   Question23  p=new Question23();
    p.print(p);
  }

Q4. Complete the code segment to call default constructor first and then any other constructor in the class.

Code:-

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

Q5. Complete the code segment to debug / complete the program which is intended to print ‘NPTEL JAVA’.

Code:-



String nptel="NPTEL";

String space=" ";


String java="JAVA";

Disclaimer:- We do not claim 100% surety of solutions, these solutions are based on our sole expertise, and by using posting these answers we are simply looking to help students as a reference, so we urge do your assignment on your own.

For More NPTEL Answers:- CLICK HERE

Join Our Telegram:- CLICK HERE

What is 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.

CRITERIA TO GET A CERTIFICATE

Average assignment score = 25% of the 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 THE 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.

Below you can find the answers for NPTEL Programming In Java Assignment 2

NPTEL Programming In Java Assignment 2 Answers [Jan 2022]

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

Code:-

// Creating object of class Student
		Student student = new Student();
		// Call 'print()' method of class Student 
		student.print();
		// Creating object of class School
		School school = new School();
		// Call 'print()' method of class School
		school.print();

Programming In Java Assignment 1 Answers 2022

Q2. Complete the code segment to call the method  print() of class given class Printer to print the following.

Code:-

// Create an object of class Printer

Printer p = new Printer();

// Call 'print()' methods for desired output

p.print("Hi! I am class STUDENT");
p.print();

Q3. Complete the code segment to call print() method of class Question by creating a method named ‘studentMethod()’.

Code:-

// Define a method named 'studentMethod()' in class Question
void studentMethod(){
// Call the method named 'print()' in class Question
		print(this);
	}

Q4. Complete the code segment to call default constructor first and then any other constructor in the class.

Code:-

// This is the class Answer
class Answer{
	// This is the default constructor of the class Answer
	Answer(){
		System.out.println("You got nothing.");
	}
	// This is a parameterized constructor of the class Answer
	Answer(int marks, String type){
		//The 'this()' referene variable is able to call the default constructor of the class.
		this();		
		//Print marks and type of the question
		System.out.println("You got "+marks+" for an "+ type);
	}
}

Q5. Complete the code segment to debug / complete the program which is intended to print ‘NPTEL JAVA’.

Code:-

//Declare variable with name 'nptel', 'space' and 'java' and proper datatype
String nptel, space, java;

//Initialize the variables with proper input
nptel = "NPTEL";
space = " ";
java = "JAVA";

Programming In Java Assignment 1 Answers 2022

Disclaimer:- We do not claim 100% surety of solutions, these solutions are based on our sole expertise, and by using posting these answers we are simply looking to help students as a reference, so we urge do your assignment on your own.

For More NPTEL Answers:- CLICK HERE

Join Our Telegram:- CLICK HERE

Programming In Java Assignment 2 Answers 2022:- All the Answers provided here to help the students as a reference, You must submit your assignment at your own knowledge

If you found this article Interesting and helpful, don’t forget to share it with your friends to get this information.

Leave a Comment