Programming in Java | NPTEL 2023 | Week 5 quiz solutions

This set of MCQ(multiple choice questions) focuses on the Programming in Java NPTEL Week 5 Quiz Solutions.

Course layout (Answers Link)

Answers COMING SOON! Kindly Wait!

NOTE: You can check your answer immediately by clicking show answer button. Programming in Java NPTEL Week 5 Quiz Solutions” contains 10 questions.

Now, start attempting the quiz.

Programming in Java NPTEL Week 5 Quiz Solutions

Q1. If the program is executed, then what will be the output?

a) 20
b) 21
c) 19
d) 22

Answer: b) 21

Programming in Java NPTEL Week 5 quiz Solutions

Q2. Which of the following statement(s) is/are false?
1. A class can extend more than one class.
2. An interface can extend many interfaces.
3. An interface can implement many interfaces.
4. A class can extend one class and implement many interfaces.

a) 1
b) 2
c) 3
d) 4

Answer: a), c)

Q3. What is the output of the following code?

a) 1
b) 2
c) 0
d) Compiler error

Answer: c) 0

Programming in Java NPTEL Week 5 quiz Solutions

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

a) Interface can provide the implementation of an abstract class.
b) The variables defined inside an interface are static and final by default.
c) An interface is used to achieve full abstraction.
d) Inside an interface, a constructor can be called using the super keyword with hierarchy.

Answer: a), d)

Q5. What is the output of the following code?

a) java
b) java
course
c) nptel
course
d) Compiler error

Answer: d) Compiler error

Q6. Which of the following keywords is/are a part of exception handling?

a) finally
b) throws
c) throw
d) thrown

Answer: a), b), c)

Q7. Fill in the blank in the above program to print the output “Java”.

a) public void
b) void
c) private void
d) static void

Answer: a) public void

Programming in Java NPTEL Week 5 quiz Solutions

Q8. Exception class exist in which of the following package?

a) java.void
b) java.io
c) java.lang
d) java.awt

Answer: c) java.lang

Q9. Fill in the blank with appropriate syntax for creating an object “c” to run the above program successfully.

a) X c = new X(1);
b) X c = new X();
c) X.Question c = new X.Question(0);
d) X.Question c = new X.Question(1);

Answer: c), d)

Q10. If the program is executed, then how many times “Java” will print?

a) 0
b) 1
c) 2
d) 3

Answer: c) 2

Programming in Java NPTEL Week 5 quiz Solutions

Programming in Java NPTEL Week 5 Quiz Solutions (2022)

Q1. If the program is executed, then what will be the output from the execution?

a) 100
102
b) 20
22
c) 102
100
d) 22
20

Answer: a)

Programming in Java NPTEL Week 5 quiz Solutions

Q2. If the program is executed, then what will be the output from the execution?

a) 170
b) 130
c) 0
d) 260

Answer: a) 170

Q3. What is the output of the following code?

a) Output: This is Explanation’s Print method
This is Answer’s Print method
b) Error: ‘super.super’ is not allowed.
c) Error: Compilation unsuccessful, as there is only one super class of Answer.
d) Output: This is Answer’s Print method
This is Explanation’s Print method

Answer: b) Error: ‘super.super’ is not allowed.

Q4. Which of the following is/are interface(s)?

a) DriverManager
b) Connection
c) Statement
d) ResultSet

Answer: b), c), d)

Programming in Java NPTEL Week 5 quiz Solutions

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

a) You can write a new instance method in the subclass that has the same signature as the one in the superclass, thus overriding it.
b) You can write a new static method in the subclass that has the same signature as the one in the superclass, thud hiding it.
c) A subclass inherits all of the public and protected members of its parent, no matter what package the subclass is in.
d) You cannot declare new methods in the subclass that are not in the superclass.

Answer: a), b), c)

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

a) Static methods in interfaces are never inherited.
b) You will get a compile-time error if you attempt to change an instance method in the superclass to a static method in the subclass.
c) You can prevent a class from being sub classed by using the final keyword in the class’s declaration.
d) An abstract class can only be subclassed; it cannot be instantiated

Answer: a), b), c), d)

Q7. Which of the following statement(s) is/are correct?

a) There is no main() method so the program is not compile successfully.
b) The value of i will be printed as 22, as it is static and final by default
c) The value of i will printed as 2, as it is initialized in class B.
d) Compile time error.

Answer: d) Compile time error.

Programming in Java NPTEL Week 5 quiz Solutions

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

a) A class can extend more than one class.
b) An interface can extend many interfaces.
c) An interface can implement many interfaces.
d) A class can extend one class and implement many interfaces.

Answer: b), d)

Programming in Java NPTEL Week 5 quiz Solutions

Q9. All classes in Java are inherited from which class?

a) java.lang.class
b) java.class.inherited
c) java.class.object
d) jaja.lang.Object

Answer: d) jaja.lang.Object

Q10. If the program is executed, then what will be the output from the execution?

a) Output: 1020
b) Output: 30
c) Output: 2010
d) Error: C1 is abstract; cannot be instantiated.

Answer: d) Error: C1 is abstract; cannot be instantiated.

Previous Course – Programming in Java NPTEL Week 5 Quiz Solutions

Q1. Which of the following is not true about throw

a) Throw is used inside a function
b) Throw can be used to declare multiple exception
c) Throw is followed by an instance
d) Throw is a keyword

Answer: b) Throw can be used to declare multiple exception

Programming in Java NPTEL Week 5 quiz Solutions

Q2. Which of the following is not true about custom exception in java?

a. class Exception extends Exp {
                     public Exception () {super ();}
                     public Exception (String s) {super(s);}
   }
b. class Exception extends Exp{
                     Exception(String s){
                                  super(s);
                     }
     }
c. public class Exception extends Exp {
                    public Exception(String s) {
                                  super(s);
                    }
    }
d. class Exception extends Exp {
                    public Exception () {super ();}

Answer: d)

Q3. Which of the following is not a property of tagged interface?

a) Serializable
b) Cloneable
c) Remote
d) Cascading

Answer: d) Cascading

Q4. Which of the following is not an exception in Java?

a) SQLException
b) ArrayIndexOutOfBoundException
c) OutOfMemoryError
d) StackOverflow

Answer: d) StackOverflow

Programming in Java NPTEL Week 5 quiz Solutions

Q5. Which of the following is type of Java Exception?

a) unchecked
b) checked
c) a & b
d) error

Answer: c) a & b

Programming in Java NPTEL Week 5 quiz Solutions

Q6. Which of the following keywords is not a part of exception handling?

a) try
b) throws
c) throw
d) thrown

Answer: d) thrown

Q7. Which of the option is correct regarding multiple catch blocks?

a) The subclass exception cannot be caught at first
b) The superclass exception cannot be caught at first
c) The subclass exception must be caught at last
d) The superclass exception must be caught at first

Answer: b) The superclass exception cannot be caught at first

Programming in Java NPTEL Week 5 Quiz solutions

Q8. When an array element is accessed beyond the array size, then which exception occurs

a) ArrayElementOutOfBound
b) ArrayIndexOutOfBound
c) ArraySizeOutOfBound
d) None of the above

Answer: d) None of the above

Q9. What is the output of this program?

class ExceptionHandling{
  public static void main(String args[]) {
     try{
       int num1, num2;
       num1 = 5;
       num2 = num1/0;
       System.out.print("A");
     }
     catch(ArithmeticException e) {
       System.out.print("0");
     }
     finally {
       System.out.print("B");
     }
  }
}

a) 0
b) A
c) 0
d) 0B

Answer: d) 0B

Q10. When does an exception occur?

a) During the time of compilation of a Java program
b) During the time of execution of a Java program
c) Anytime, that is, during compilation and execution of a program
d) At the end of execution of a Java program, if there is an exception

Answer: b) During the time of execution of a Java program

Programming in Java NPTEL Week 5 quiz Solutions

>> Next- Programming in Java Week 4 Assignment Solutions

>> Next- Programming in Java Week 6 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.

Nptel – Deep Learning assignment solutions

Social Networks nptel assignment answers

NPTEL answers: Programming in Modern C++

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.

Leave a Comment

Your email address will not be published. Required fields are marked *