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.

You must login to ask a question.

Programming in Java Week 2 Assignment Answers 2022

NPTEL Java Week 2 Assignment Answers, Hints, Solution

Programming in java banner to the nptel week 2 assignment

Students, here, in this article I have provided nptel java week 2 assignment answers hints. You can follow these hints to solve your java assignment before the last date.

NPTEL Programming in Java Week 2 Assignment Answers

Q1. 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. 64

For instant notification of any updates, Join us on telegram.


Q2. 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. javadoc


Q3. Following is a program given for this question.

public class Main{
public static void main(String[] args) {
char[] copyFrom = { 'j', 'a', 'n', 'n', 'p', 't',
'e', 'l', 'j', 'a', 'v', 'a', }; 
char[] copyTo = new char[9];
System.arraycopy(copyFrom,3, copyTo, 0, 9);

What will be the output of the above program?

a. javanptel

b. npteljava

c. janjavanptel

d. jannpteljava

Answer: b. npteljava


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

public class Question {
public static void main(String[] args) {
for (String s: args) { System.out.println(s+args[0]);
}
}
}

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

Input:

A: “jan java nptel”
B: 1 2 3

a. A: jannptel
javanptel
nptelnptel

b. A: jan java nptel jan java nptel

c. B: 11
21
31

d. B: 12 3 1

Answer: b. A: jan java nptel jan java nptel
c. B: 11

21

31


Q5. 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. println() prints and then appends a line break.


Q6. 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. Greentalk


Q7. 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 Foo();

d.  new Foo obj;

Answer: c. Foo obj = new Foo();


Q8. Following is a program given for this question.

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

 boolean m=Integer.valueOf (0).equals(Long.valueOf(1)); 
System.out.println(m);
}

What will be the output of the above program?

a. 0

b. 1

c. false

d. true

Answer: c. false


Q9. 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. Scanner class can be used by passing the predefined object System.in


Q10. What is the output of the following program?

a. 14

b. 12

c. 15

d. 17

Answer: d. 17


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

Disclaimer: These answers are provided only for the purpose of helping students to take references. This website does not claim any surety of 100% correct answers. So, this website urges you to complete your assignment yourself.


Also Available:

NPTEL Programming in Java Week 1 Assignment Answers

Related Posts