NPTEL Programming In Java Week 4 Assignment Answers 2022
NPTEL Programming In Java Week 4 Assignment Answers
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. Packages are used to organize a set of related classes and interfaces.
b. Packages are used for preventing naming conflicts.
c. Packages provide code reusabilty.
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: Option b, c and 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
Comments
Post a Comment