SlideShare a Scribd company logo
1 of 5
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

Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in JavaJin Castor
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in javaGoogle
 
Exception handling c++
Exception handling c++Exception handling c++
Exception handling c++Jayant Dalvi
 
java memory management & gc
java memory management & gcjava memory management & gc
java memory management & gcexsuns
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Elizabeth alexander
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C v_jk
 
Regular Expressions in Java
Regular Expressions in JavaRegular Expressions in Java
Regular Expressions in JavaOblivionWalker
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handlingkamal kotecha
 
Java Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and StreamsJava Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and StreamsAnton Keks
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in JavaSpotle.ai
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructorsNilesh Dalvi
 
LINUX:Control statements in shell programming
LINUX:Control statements in shell programmingLINUX:Control statements in shell programming
LINUX:Control statements in shell programmingbhatvijetha
 

What's hot (20)

Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
 
[OOP - Lec 18] Static Data Member
[OOP - Lec 18] Static Data Member[OOP - Lec 18] Static Data Member
[OOP - Lec 18] Static Data Member
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
 
Constructor and destructor
Constructor  and  destructor Constructor  and  destructor
Constructor and destructor
 
Exception handling c++
Exception handling c++Exception handling c++
Exception handling c++
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
 
java memory management & gc
java memory management & gcjava memory management & gc
java memory management & gc
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C
 
Regular Expressions in Java
Regular Expressions in JavaRegular Expressions in Java
Regular Expressions in Java
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
 
Java I/O
Java I/OJava I/O
Java I/O
 
Java Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and StreamsJava Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and Streams
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
 
Java threads
Java threadsJava threads
Java threads
 
GUI components in Java
GUI components in JavaGUI components in Java
GUI components in Java
 
Queues
QueuesQueues
Queues
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
LINUX:Control statements in shell programming
LINUX:Control statements in shell programmingLINUX:Control statements in shell programming
LINUX:Control statements in shell programming
 

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 assertionsHari kiran G
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in javaAmbigaMurugesan
 
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 inheritanceAbishek 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 .pdfmayorothenguyenhob69
 
200 mcq c++(Ankit dubey)
200 mcq c++(Ankit dubey)200 mcq c++(Ankit dubey)
200 mcq c++(Ankit dubey)Ankit Dubey
 
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 developmentrohitgudasi18
 
Technical aptitude Test 1 CSE
Technical aptitude Test 1 CSETechnical aptitude Test 1 CSE
Technical aptitude Test 1 CSESujata 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
 
C __paper.docx_final
C __paper.docx_finalC __paper.docx_final
C __paper.docx_finalSumit 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

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

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 

Recently uploaded (20)

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 

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.