SlideShare a Scribd company logo
abishekvk@outlook.com
1. If a statement tries to divide by zero which exception is thrown?
A. ArithemticException
B. NullPointerException
C. NumberFormatException
D. None of these
2. Which of these keywords is not a part of exception handling?
A. try
B. finally
C. thrown
D. catch
3. Which of these keywords must be used to monitor for exceptions?
A. try
B. finally
C. throw
D. catch
4. Which of these class is related to all the exceptions that can be caught by using
catch?
A. Error
B. Exception
C. RuntimeExecption
D. All of the mentioned
5. Which of these handles the exception when no catch is used?
A. Default handler
B. finally
C. throw handler
D. Java run time system
6. Which of these keywords is used to manually throw an exception?
A. try
B. finally
C. throw
D. catch
7. If an exception is generated in try block , then it is caught in ____ block
A. finally
B. throw
C. throws
D. catch
abishekvk@outlook.com
8. ______ is a superclass of all exception classes.
A. Exception
B. Throwable
C. RuntimeException
D. IOException
9. To create our own exception class , we have to _______
A. Extend exception class
B. Create our own try and catch block
C. use finally block
D. Use throws keyword
10. What is the output of following try catch block try
try
{
int i;
return;
}
catch(Exception e)
{
System.out.println('Hello India―);
}
finally
{
System.out.println('Hello Morbi―);
}
A. Hello India
B. Hello India Hello Morbi
C. Hello Morbi
D. the program will return without printing anything
11. What will be the output of the program?
try { int x = 0; int y = 5 / x; }
catch (Exception e)
{ System.out.println("Exception"); }
catch (ArithmeticException ae)
{ System.out.println(" Arithmetic Exception"); }
System.out.println("finished");
A. finished
B. Exception
C. Compilation fails.
abishekvk@outlook.com
D. Arithmetic Exception
12. What will be the output of the program?
public class X
{
public static void main(String [] args)
{
try { badMethod();
System.out.print("A"); }
catch (Exception ex)
{ System.out.print("B"); }
finally { System.out.print("C"); }
System.out.print("D");
}
public static void badMethod()
{ throw new Error(); /* Line 22 */ }
}
A. ABCD
B. Compilation fails.
C. C is printed before exiting with an error message.
D. BC is printed before exiting with an error message.
13. Which of these access specifiers can be used for an interface?
A. Public
B. Protected
C. private
D. All of the mentioned
14. Which of these keywords is used by a class to use an interface defined
previously?
A. import
B. Import
C. implements
D. Implements
15. Which of the following is correct way of implementing an interface salary by class
manager?
abishekvk@outlook.com
A. class manager extends salary {}
B. class manager implements salary {}
C. class manager imports salary {}
D. None of the mentioned.
16. What is the output of this program?
interface calculate {
void cal(int item);
}
class display implements calculate
{
int x;
public void cal(int item)
{
x = item * item;
}
}
class interfaces
{
public static void main(String args[])
{
display arr = new display;
arr.x = 0;
arr.cal(2);
System.out.print(arr.x);
}
}
A. 0
B. 2
C. 4
D. None of the mentioned
17. Giventhe followingpiece of code:
publicinterface Guard
{
voiddoYourJob();
}
abstract publicclassDog implementsGuard{ }
Whichof the followingstatementsiscorrect?
A. Thiscode will notcompile,becausemethoddoYourJob()ininterfaceGuardmust
be definedabstract.
abishekvk@outlook.com
B. Thiscode will notcompile,because classDogmustimplementmethod
doYourJob() frominterface Guard.
C. Thiscode will notcompile,because inthe declarationof classDogwe must use
the keywordextendsinsteadof implements.
D. Thiscode will compilewithoutanyerrors.
18. Interfaces helps in which type of inheritance ?
A. Multiple inheritance
B. Multi-level inheritance
C. Hierarchical Inheritance
D. Multipath inheritance
19. Which of the following is true about interfaces in java.
1) An interface can contain following type of members.
....public, static, final fields (i.e., constants)
....default and static methods with bodies
2) An instance of interface can be created.
3) A class can implement multiple interfaces.
4) Many classes can implement the same interface.
A. 1, 3 and 4
B. 1, 2 and 4
C. 2, 3 and 4
D. 1, 2, 3 and 4
20. Which of these can be used to fully abstract a class from its implementation?
A. Objects
B. Packages
C. Interfaces
D. None of the Mentioned.

More Related Content

What's hot

Java IO
Java IOJava IO
Java IO
UTSAB NEUPANE
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
kamal kotecha
 
7 rules of simple and maintainable code
7 rules of simple and maintainable code7 rules of simple and maintainable code
7 rules of simple and maintainable code
Geshan Manandhar
 
Java/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCJava/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBC
FAKHRUN NISHA
 
Super Keyword in Java.pptx
Super Keyword in Java.pptxSuper Keyword in Java.pptx
Super Keyword in Java.pptx
KrutikaWankhade1
 
Final keyword in java
Final keyword in javaFinal keyword in java
Final keyword in java
Hitesh Kumar
 
Wrapper class
Wrapper classWrapper class
Wrapper class
kamal kotecha
 
Pre defined Functions in C
Pre defined Functions in CPre defined Functions in C
Pre defined Functions in C
Prabhu Govind
 
String and string buffer
String and string bufferString and string buffer
String and string bufferkamal kotecha
 
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
Kuntal Bhowmick
 
Interface in java
Interface in javaInterface in java
Interface in java
PhD Research Scholar
 
Java Basic Oops Concept
Java Basic Oops ConceptJava Basic Oops Concept
Java Basic Oops Concept
atozknowledge .com
 
Code Coverage
Code CoverageCode Coverage
Code Coverage
Ernani Omar Cruz
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
arvind pandey
 
Methods in java
Methods in javaMethods in java
Methods in java
chauhankapil
 
Exception handling
Exception handlingException handling
Exception handling
Pranali Chaudhari
 
Packages in java
Packages in javaPackages in java
Packages in java
Elizabeth alexander
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
Nilesh Dalvi
 
GUI programming
GUI programmingGUI programming
GUI programming
Vineeta Garg
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
lalithambiga kamaraj
 

What's hot (20)

Java IO
Java IOJava IO
Java IO
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
7 rules of simple and maintainable code
7 rules of simple and maintainable code7 rules of simple and maintainable code
7 rules of simple and maintainable code
 
Java/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCJava/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBC
 
Super Keyword in Java.pptx
Super Keyword in Java.pptxSuper Keyword in Java.pptx
Super Keyword in Java.pptx
 
Final keyword in java
Final keyword in javaFinal keyword in java
Final keyword in java
 
Wrapper class
Wrapper classWrapper class
Wrapper class
 
Pre defined Functions in C
Pre defined Functions in CPre defined Functions in C
Pre defined Functions in C
 
String and string buffer
String and string bufferString and string buffer
String and string buffer
 
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
 
Interface in java
Interface in javaInterface in java
Interface in java
 
Java Basic Oops Concept
Java Basic Oops ConceptJava Basic Oops Concept
Java Basic Oops Concept
 
Code Coverage
Code CoverageCode Coverage
Code Coverage
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
Methods in java
Methods in javaMethods in java
Methods in java
 
Exception handling
Exception handlingException handling
Exception handling
 
Packages in java
Packages in javaPackages in java
Packages in java
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
 
GUI programming
GUI programmingGUI programming
GUI programming
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
 

Similar to Multiple Choice Questions for Java interfaces and exception handling

OCJP Samples Questions: Exceptions and assertions
OCJP Samples Questions: Exceptions and assertionsOCJP Samples Questions: Exceptions and assertions
OCJP Samples Questions: Exceptions and assertions
Hari kiran G
 
Exception handling
Exception handlingException handling
Exception handling
PhD Research Scholar
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
AmbigaMurugesan
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
Md. Tanvir Hossain
 
Exceptions
ExceptionsExceptions
Exceptions
Soham Sengupta
 
Java Quiz
Java QuizJava Quiz
Java Quiz
Dharmraj Sharma
 
Multiple choice questions for Java io,files and inheritance
Multiple choice questions for Java io,files and inheritanceMultiple choice questions for Java io,files and inheritance
Multiple choice questions for Java io,files and inheritance
Abishek Purushothaman
 
Exception handling
Exception handlingException handling
Exception handlingIblesoft
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdf
mayorothenguyenhob69
 
Part - 2 Cpp programming Solved MCQ
Part - 2  Cpp programming Solved MCQ Part - 2  Cpp programming Solved MCQ
Part - 2 Cpp programming Solved MCQ
Knowledge Center Computer
 
Html
HtmlHtml
200 mcq c++(Ankit dubey)
200 mcq c++(Ankit dubey)200 mcq c++(Ankit dubey)
200 mcq c++(Ankit dubey)
Ankit Dubey
 
CORE JAVA
CORE JAVACORE JAVA
CORE JAVA
Shohan Ahmed
 
Unit II Java & J2EE regarding Java application development
Unit II Java & J2EE regarding Java application developmentUnit II Java & J2EE regarding Java application development
Unit II Java & J2EE regarding Java application development
rohitgudasi18
 
Technical aptitude Test 1 CSE
Technical aptitude Test 1 CSETechnical aptitude Test 1 CSE
Technical aptitude Test 1 CSE
Sujata Regoti
 
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Udayan Khattry
 
Java Programming.pdf
Java Programming.pdfJava Programming.pdf
Java Programming.pdf
RavinderKSingla
 
C __paper.docx_final
C __paper.docx_finalC __paper.docx_final
C __paper.docx_final
Sumit Sar
 

Similar to Multiple Choice Questions for Java interfaces and exception handling (20)

OCJP Samples Questions: Exceptions and assertions
OCJP Samples Questions: Exceptions and assertionsOCJP Samples Questions: Exceptions and assertions
OCJP Samples Questions: Exceptions and assertions
 
Exception handling
Exception handlingException handling
Exception handling
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
 
Exceptions
ExceptionsExceptions
Exceptions
 
Java Day-5
Java Day-5Java Day-5
Java Day-5
 
Java Quiz
Java QuizJava Quiz
Java Quiz
 
Multiple choice questions for Java io,files and inheritance
Multiple choice questions for Java io,files and inheritanceMultiple choice questions for Java io,files and inheritance
Multiple choice questions for Java io,files and inheritance
 
Exception handling
Exception handlingException handling
Exception handling
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdf
 
Part - 2 Cpp programming Solved MCQ
Part - 2  Cpp programming Solved MCQ Part - 2  Cpp programming Solved MCQ
Part - 2 Cpp programming Solved MCQ
 
Html
HtmlHtml
Html
 
200 mcq c++(Ankit dubey)
200 mcq c++(Ankit dubey)200 mcq c++(Ankit dubey)
200 mcq c++(Ankit dubey)
 
CORE JAVA
CORE JAVACORE JAVA
CORE JAVA
 
Java unit3
Java unit3Java unit3
Java unit3
 
Unit II Java & J2EE regarding Java application development
Unit II Java & J2EE regarding Java application developmentUnit II Java & J2EE regarding Java application development
Unit II Java & J2EE regarding Java application development
 
Technical aptitude Test 1 CSE
Technical aptitude Test 1 CSETechnical aptitude Test 1 CSE
Technical aptitude Test 1 CSE
 
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
 
Java Programming.pdf
Java Programming.pdfJava Programming.pdf
Java Programming.pdf
 
C __paper.docx_final
C __paper.docx_finalC __paper.docx_final
C __paper.docx_final
 

More from Abishek Purushothaman

Aws solution architect
Aws solution architectAws solution architect
Aws solution architect
Abishek Purushothaman
 
Machine learning
Machine learningMachine learning
Machine learning
Abishek Purushothaman
 
Introduction to R for beginners
Introduction to R for beginnersIntroduction to R for beginners
Introduction to R for beginners
Abishek Purushothaman
 
Mini Project presentation for MCA
Mini Project presentation for MCAMini Project presentation for MCA
Mini Project presentation for MCA
Abishek Purushothaman
 
Python Programming Basics for begginners
Python Programming Basics for begginnersPython Programming Basics for begginners
Python Programming Basics for begginners
Abishek Purushothaman
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
Abishek Purushothaman
 
Exception handling
Exception handlingException handling
Exception handling
Abishek Purushothaman
 

More from Abishek Purushothaman (7)

Aws solution architect
Aws solution architectAws solution architect
Aws solution architect
 
Machine learning
Machine learningMachine learning
Machine learning
 
Introduction to R for beginners
Introduction to R for beginnersIntroduction to R for beginners
Introduction to R for beginners
 
Mini Project presentation for MCA
Mini Project presentation for MCAMini Project presentation for MCA
Mini Project presentation for MCA
 
Python Programming Basics for begginners
Python Programming Basics for begginnersPython Programming Basics for begginners
Python Programming Basics for begginners
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
 
Exception handling
Exception handlingException handling
Exception handling
 

Recently uploaded

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 

Recently uploaded (20)

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 

Multiple Choice Questions for Java interfaces and exception handling

  • 1. abishekvk@outlook.com 1. If a statement tries to divide by zero which exception is thrown? A. ArithemticException B. NullPointerException C. NumberFormatException D. None of these 2. Which of these keywords is not a part of exception handling? A. try B. finally C. thrown D. catch 3. Which of these keywords must be used to monitor for exceptions? A. try B. finally C. throw D. catch 4. Which of these class is related to all the exceptions that can be caught by using catch? A. Error B. Exception C. RuntimeExecption D. All of the mentioned 5. Which of these handles the exception when no catch is used? A. Default handler B. finally C. throw handler D. Java run time system 6. Which of these keywords is used to manually throw an exception? A. try B. finally C. throw D. catch 7. If an exception is generated in try block , then it is caught in ____ block A. finally B. throw C. throws D. catch
  • 2. abishekvk@outlook.com 8. ______ is a superclass of all exception classes. A. Exception B. Throwable C. RuntimeException D. IOException 9. To create our own exception class , we have to _______ A. Extend exception class B. Create our own try and catch block C. use finally block D. Use throws keyword 10. What is the output of following try catch block try try { int i; return; } catch(Exception e) { System.out.println('Hello India―); } finally { System.out.println('Hello Morbi―); } A. Hello India B. Hello India Hello Morbi C. Hello Morbi D. the program will return without printing anything 11. What will be the output of the program? try { int x = 0; int y = 5 / x; } catch (Exception e) { System.out.println("Exception"); } catch (ArithmeticException ae) { System.out.println(" Arithmetic Exception"); } System.out.println("finished"); A. finished B. Exception C. Compilation fails.
  • 3. abishekvk@outlook.com D. Arithmetic Exception 12. What will be the output of the program? public class X { public static void main(String [] args) { try { badMethod(); System.out.print("A"); } catch (Exception ex) { System.out.print("B"); } finally { System.out.print("C"); } System.out.print("D"); } public static void badMethod() { throw new Error(); /* Line 22 */ } } A. ABCD B. Compilation fails. C. C is printed before exiting with an error message. D. BC is printed before exiting with an error message. 13. Which of these access specifiers can be used for an interface? A. Public B. Protected C. private D. All of the mentioned 14. Which of these keywords is used by a class to use an interface defined previously? A. import B. Import C. implements D. Implements 15. Which of the following is correct way of implementing an interface salary by class manager?
  • 4. abishekvk@outlook.com A. class manager extends salary {} B. class manager implements salary {} C. class manager imports salary {} D. None of the mentioned. 16. What is the output of this program? interface calculate { void cal(int item); } class display implements calculate { int x; public void cal(int item) { x = item * item; } } class interfaces { public static void main(String args[]) { display arr = new display; arr.x = 0; arr.cal(2); System.out.print(arr.x); } } A. 0 B. 2 C. 4 D. None of the mentioned 17. Giventhe followingpiece of code: publicinterface Guard { voiddoYourJob(); } abstract publicclassDog implementsGuard{ } Whichof the followingstatementsiscorrect? A. Thiscode will notcompile,becausemethoddoYourJob()ininterfaceGuardmust be definedabstract.
  • 5. abishekvk@outlook.com B. Thiscode will notcompile,because classDogmustimplementmethod doYourJob() frominterface Guard. C. Thiscode will notcompile,because inthe declarationof classDogwe must use the keywordextendsinsteadof implements. D. Thiscode will compilewithoutanyerrors. 18. Interfaces helps in which type of inheritance ? A. Multiple inheritance B. Multi-level inheritance C. Hierarchical Inheritance D. Multipath inheritance 19. Which of the following is true about interfaces in java. 1) An interface can contain following type of members. ....public, static, final fields (i.e., constants) ....default and static methods with bodies 2) An instance of interface can be created. 3) A class can implement multiple interfaces. 4) Many classes can implement the same interface. A. 1, 3 and 4 B. 1, 2 and 4 C. 2, 3 and 4 D. 1, 2, 3 and 4 20. Which of these can be used to fully abstract a class from its implementation? A. Objects B. Packages C. Interfaces D. None of the Mentioned.