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.

NPTEL Programming in Java Assignment 4 Answers 2022

NPTEL Programming in Java Assignment 4 Answers 2022 (Week 4)

Q1. Which of the following statement(s) is/are true?

a. The default package in the Java language is java.lang
b. String is a final class and it is present in java.lang package
c. Runnable is a class present in java.lang package
d. Thread is a class present in java.lang package

Answer: a. The default package in the Java language is java.lang
b. String is a final class and it is present in java.lang package
d. Thread is a class present in java.lang package


Q2. Which of the following statement(s) is/are false?

a. With the import statement, generally import only a single package member or an entire package
b. To import all the types contained in a particular package, use the import statement with the asterisk() wildcard character. import package.;
c. import package.A; it used to match a subset of the classes in a package starts with “A”

d. import package.A; it generates compilation error

Answer: c. import package.A; it used to match a subset of the classes in a package starts with “A”


Q3. Which of the following is/are class(s) of java.awt package?

a. CardLayout
b. Checkbox
c. Choice
d. MenuContainer

Answer: a. CardLayout
b. Checkbox
c. Choice


Q4. Which of these access specifiers(s) can be used for an interface?

a. public
b. protected
c. private
d. Both b and c

Answer: a. public


Q5. Consider the program given below.

import static java.lang.Math.*;
public class Main{
  
      public static void main (String args[]) {

             System.out.println(cos(3*PI));

      }
}

What will be the output if the above program is executed?

a. It will give compile-time error
b. It will give run-time error
c. -1.0
d. 3.14

Answer: c. -1.0


Q6. Which of the following packages is used to includes utility classes like Calendar, Collection, Date?

a. java.lang
b. java.util
c. java.net
d. java.awt

Answer: b. java.util


Q7. Consider the program given below.

import static java.lang.System.*;
public class Question{
   public static void main(String args[])
   {
       out.println("JAVA");
   }
}

What will be the output if the above program is executed?

a. It will give compile-time error
b. It will give run-time error
c. JAVA
d. JAV

Answer: c. JAVA


Q8. Which of the following is/are NOT valid declaration(s) of an interface?

a. public interface Question{
void method (int value){
System.out.printIn(“Nptel”);
}
}

b. public interface Question {
void method (int value){

}
}

c. public interface Question {

}


d. public interface Question{

default void method (int value){
System.out.printIn(“Nptel”);

}

}

Answer: a. public interface Question{
void method (int value){
System.out.printIn(“Nptel”);
}
}


Q9. Which of the following is false statement about interface in java?

a. An interface can extend other interfaces
b. The interface body can contain abstract methods, default methods, and static methods
c. All constant values defined in an interface are implicitly public, static, and final
d. A static method in an interface are implicitly private

Answer: d. A static method in an interface are implicitly private


Q10. Which of the following statement(s) is/are true?

a. The default package in the Java language is java.lang
b. String is a final class and it is present in java.lang package
c. Cloneable is an interface in java.lang package
d. Thread is a class present in java.lang package

Answer: a. The default package in the Java language is java.lang
b. String is a final class and it is present in java.lang package
d. Thread is a class present in java.lang package


Disclaimer: These answers are provided only for the purpose to help 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:

Programming in Java NPTEL Assignment Solutions

NPTEL Ethical Hacking Assignment 4 Answers

Related Posts