This set of MCQ(multiple choice questions) focuses on the Programming in Java NPTEL 2023 Week 4 Quiz Solutions.
Course layout (Answers Link)
Answers COMING SOON! Kindly Wait!
Week 1: Overview of Object-Oriented Programming and Java
Programming Assignment
Week 2: Java Programming Elements
Programming Assignment
Week 3: Input-Output Handling in Java
Programming Assignment
Week 4: Encapsulation
Programming Assignment
Week 5: Inheritance
Programming Assignment
Week 6: Exception Handling
Programming Assignment
Week 7: Multithreaded Programming
Programming Assignment
Week 8: Java Applets and Servlets
Programming Assignment
Week 9: Java Swing and Abstract Windowing Toolkit
Week 10: Networking with Java
Week 11: Java Object Database Connectivity
Week 12: Interface and Packages for Software Development
NOTE: You can check your answer immediately by clicking show answer button. Programming in Java NPTEL 2023 Week 4 Quiz Solutions” contains 10 questions.
Now, start attempting the quiz.
Programming in Java NPTEL 2023 Week 4 Quiz Solutions
Q1. Which of the following is the correct statement for creating a package?
a) <package name> package;
b) package <package name>;
c) package;
d) <package name>;
Answer: b)
Q2. 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.
Answer: a), b), c)
Q3. Which of the following statement(s) 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 keyword is a non-access modifier.
Answer: a)
Q4. 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.
Answer: d)
Q5. 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 error
c) 1.0
d) 3.14
Answer: a)
Q6. 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
Answer: b), d)
Q7. Which of the following is required for developing a Java program?
a) JDK
b) JRE
c) JDK without JRE
d) JRE without JDK
Answer: a)
Q8. Which of the following is/are valid declaration(s) of an interface?
Answer: b), c), d)
Q9. Which of the following statement(s) 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.
Answer: c)
Q10. Which of the following statement(s) 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.
Answer: a), b), d)
Programming in Java NPTEL 2023 Week 4 Quiz Solutions
Q1. Which of the following is the correct statement for creating a package?
a) <package name> package;
b) package <package name>;
c) package;
d) <package name>;
Answer: b)
Q2. Which of the following source files cannot be included in a package?
a) classes
b) interfaces
c) enumerations
d) data
Answer: d)
Q3. Which of the following is/are used to access a public package?
a) Refer to the member by its fully qualified name
b) Import the package member
c) Import the member’s entire package
d) Import is not mandatory
Answer: a), b), c)
Q4. Which of the following statement(s) is/are false?
a) Java package are hierarchical
b) System.out.println() is a predefined java function
c) Java can have a nested class structure
d) The Java static keyword is a non-access modifier
Answer: b)
Q5. 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 error
c) 1.0
d) 3.14
Answer: a)
Q6. 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
Answer: b), d)
Q7. Which of the following is required for developing a Java program?
a) JDK
b) JRE
c) JDK without JRE
d) JRE without JDK
Answer: a)
Q8. Which of the following statement(s) is/are correct?
a) Java code byte is machine dependent
b) Java byte code is generated by the compiler
c) Java byte code is generated by the interpreter
d) Java byte code is machine independent
Answer: b), d)
Q9. Which of the following is an advantage of methods?
a) Code re-usability
b) Platform independence
c) Fast execution of codes
d) Removes compilation error
Answer: a)
Q10. Consider the following program:
public class Main1{
public static void main(String args[]) {
int number = 10;
system.out.println(number++ + ++number);
}
}
public class Main2{
public static void main(String args[]) {
int number = 10;
system.out.println(++number + number++);
}
}
Choose correct statement about the output of this code segment.
a) Both pre-increment and post-increment operators becomes pre-increment during print
b) Both pre-increment and post-increment operators becomes post-increment during print
c) Both Main1 and Main2 classes give the same output
d) Pre-increment and post-increment operators don’t work during print
Answer: c)
Programming in Java NPTEL 2022 Week 4 Quiz Solutions
Q1. Which of these is a mechanism for naming and visibility control of a class and its content?
a) Objects
b) Interfaces
c) Packages
d) Both a and b
Answer: c) Packages
Q2. Which of the following is false statement about packages in java?
a) Package are used to organize a set of related classes and interfaces.
b) Packages are used for preventing naming conflicts
c) Packages provide code reusability
d) Packages cannot be considered as data encapsulation
Answer: d) Packages cannot be considered as data encapsulation
Q3. Which of the following is/are interface(s) of java.awt package?
a) CardLayout
b) Checkbox
c) Choice
d) MenuContainer
Answer: d) MenuContainer
Q4. Which of the following statement(s) is/are false?
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 a class present in java.lang package
d) Thread is a class present in java.lang package
Answer: c) Cloneable is a class present in java.lang package
Q5. Consider the program given below.
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, Collections, Date?
a) java.lang
b) java.util
c) java.net
d) java.awt
Answer: b) java.util
Q7. Which of the following statement(s) is/are false?
a) Comparable interface is present in java.lang package
b) Iterator interface is present in java.util package
c) Compare() is a method used in Comparable interface
d) Serializable interface is present in java.io package
Answer: c) Compare() is a method used in Comparable interface
Q8. Which of the following is/are valid declaration(s) of an interface?
Answer: b), c), d)
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 these access specifier(s) can be used for an interface?
a) Public
b) Protected
c) Private
d) Both b and c
Answer: a) Public
Previous Course – Week 4 Quiz Solutions
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), b), d)
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)
Q3. Which of the following is/are class(s) of java.awt package?
a) CardLayout
b) Checkbox
c) Choice
d) MenuContainer
Answer: a), b), c)
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)
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)
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)
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)
Q8.
Answer: a)
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)
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), b), c), d)
>> Next- Programming in Java Week 3 Assignment Solutions
>> Next- Programming in Java Week 5 Assignment Solutions
DISCLAIMER: Use these answers only for the reference purpose. Quizermania doesn't claim these answers to be 100% correct. So, make sure you submit your assignments on the basis of your knowledge.
For discussion about any question, join the below comment section. And get the solution of your query. Also, try to share your thoughts about the topics covered in this particular quiz.