This set of MCQ(multiple choice questions) focuses on the Programming in Java NPTEL 2022 Week 12 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
Programming Assignment
Week 10: Networking with Java
Programming Assignment
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 2022 Week 12 Quiz Solutions” contains 10 questions.
Now, start attempting the quiz.
Programming in Java NPTEL 2022 Week 12 Quiz Solutions
Q1. Which statement is true in case of using “this” keyword in a static method?
a) “this” keyword can be used in static method to access static variables only
b) “this” keyword can’t be used in static method
c) “this” keyword can be used in static method
d) None
Answer: a)
Q2. State whether the following statements are True or False.
i) A catch can have comma-separated multiple arguments.
ii) Throwing an Exception always causes program termination.
a) True, False
b) False, True
c) True, True
d) False, False
Answer: d) False, False
Q3. Which of the following contains both date and time?
a) java.io.date
b) java.sql.date
c) java.util.date
d) java.util.dateTime
Answer: c) java.util.date
Q4. In Graphics class which method is used to draw a rectangle with the specified width and height?
a) public void drawRect(int x, int y, int width, int height)
b) public abstract void fillRect(int x, int y, int width, int height)
c) public abstract void drawLine(int x1, int y1, int x2, int y2)
d) public abstract void drawOval(int x, int y, int width, int height)
Answer: a)
Q5. Which of the following control expressions are valid for an if statement?
a) Any integer expression
b) Any Boolean expression
c) A String object
d) Any expression with mixed arithmetic
Answer: b) Any Boolean expression
Q6. Consider the following program:
String animal = “GOAT”;
switch(animal)
{
break: System.out.println(“DOMESTIC”);
}
What is the output of the Java program given above?
a) No output
b) GOAT
c) DOMESTIC
d) Compiler error
Answer: d) Compiler error
Q7. What is the output of the following program?
a) java
b) ava
c) y java
d) january
Answer: b) ava
Q8. Which of the following statements would cause a compilation error?
a) float[] = new float(3);
b) float f2[] = new float[];
c) float[] f1 = new float[3];
d) float f3[] = new float[3];
e) float f5[] = {1.0f, 2.0f, 2.0f};
f) float f4[] = new float[] (1.0f, 2.0f, 3.0f};
Answer: a), b)
Q9. What is the result, if the above-mentioned program is executed?
a) finally
b) finally exception finally finished
c) finally exception finished
d) Compilation fails
Answer: b) finally exception finally finished
Q10. Which is a component in AWT that can contain another components like buttons, textfields, labels etc.?
a) Window
b) Container
c) Panel
d) Frame
Answer: b) Container
Previous Course – NPTEL 2022 Week 12 Quiz Solutions
Q1. Execution of SQL command like SELECT * FROM myTable using JDBC program will return a ResultSet object. This object is
a) Same as the myTable
b) All records in verbatim from the table
c) All records in verbatim from the table but those records with null values
d) All records in verbatim from the table but those records are not with null values
Answer: b)
Q2. Which of the following control expressions are not valid for an if statement?
a) Any integer expression
b) Any Boolean expression
c) A String object
d) Any expression with mixed arithmetic
Answer: c), d)
Q3. Let’s consider the following program in Java.
If you run this program the how many threads will be executed altogether?
a) One thread only
b) Two thread only
c) Three threads only
d) No thread will run in this case
Answer: b)
Q4. Which of the statements are not correct about Swing programming?
a) AWT is a heavyweight programming
b) Swing is heavyweight programming
c) Swing is lightweight programming
d) Both AWT and Swing are lightweight programming
Answer: c)
Q5. Which of the following displays components row-by-row in the order in which they were added to the JFrame?
a) CardLayout
b) FlowLayout
c) BorderLayout
d) GridLayout
Answer: b)
Q6. What is the result, if the above-mentioned program is executed?
a) finally
b) exception finished
c) exception finally finished
d) finally exception finished
e) Compilation fails
Answer: e)
Q7. What is the output of the following program?
a) j ava
b) java
c) javanptel
d) january
Answer: b)
Q8. Which of the following statements would cause a compilation error?
a) float[] = new float(3);
b) float f2[] = new float[];
c) float[] f1 = new float[3];
d) float f3[] = new float[3];
e) float f5[] = { 1.0f, 2.0f, 2.0f };
f) float f4[] = new float[] { 1.0f, 2.0f, 3.0f};
Answer: a), b)
Q9. What is the output of the following program?
a) 16
b) 15
c) 19
d) 17
Answer: d)
Q10. Which of the following method is used to set a frame, say f with size 200 x 300 pixels?
JFrame f = new JFrame();
a) f.setSize(300, 200);
b) f.setSize(200, 300);
c) f.paint(300, 200);
d) f.setVisible(300, 200);
Answer: a)
>> Prev- Programming in Java Week 11 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.