-->

NPTEL Programming in Java week 4 Quiz Assignment Solution

                     


          nptel programming in java assignment solutions

Q1. Which of the following is the correct statement for creating a package?

a. package;
b. package «package name>;
c. package:
d. «package name>;

2. How Java Runtime Environment (JRE) knows where to look for a package that you create?
a. It searches in the current directory.
b. It searches in the location set in the CLASSPATH environment variable.
c. A user can set the path during runtime using the -classpath option.

d. Using the -path option, a user can set the path.

3. Which of the following statements) is/are false?
a. Java packages are hierarchical.
b. System.out.println () is a predefined java function.
c. Java can have a nested class structure.
d. The Java static kevword is a non-access modifier.

4. Which of the following is/are NOT correct regarding packages in Java?
a. Java supports both pre-defined and user-defined packages.
b. Packages are used to organize a set of related classes and interfaces.
c. Pre-defined packages help to develop programs easily by providing thousands of classes.
d. Packages are used to organize only a set of related classes and not interfaces.

5. Consider the program given below.

public class Main {
public static void main (String args []) {
System.out.println (cos (2*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 ertor
c. 1.0
d. 3.14

6. Which of the following is the minimum requirement for executing a Java program?
a. JDK
b. JRE
c. JDK without JRE
d. JRE without JDK

7. Which of the following is required for developing a Java program?
a. JDK
b. JRE
c. JDK without JRE
d. JRE without JDK

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

a. public interface Question {
void method (int value) {
            System.out.println ("Nptel");
        }
}
b. public interface Question {
void method (int value);
}

c. public interface Question {
}
d. public interface Question {
default void method (int value) {
System.out.println ("Nptel");

9. Which of the following statements) is/are NOT 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

10. Which of the following statements) is/are true?
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.

Post a Comment (0)
Previous Question Next Question