Become a GOLD member of Deccansoft and get access to 40+ courses!!
NewBatches/Webinars
Packages
Gold Membership
Bestseller
Microsoft Azure Suite & Suite Plus
Power Platform Acadamy
New
Azure DevOps Expert & Expert Plus
MS.NET Foundation For Beginners
MS.NET Full Stack Developer
UI / Web Development
SQL Server & MSBI Tools
Software Testing
Courses
MS.NET Courses (Includes Live Project)
Complete C#, OOPs and Windows Programing
ASP.NET MVC Online Training
ASP.NET WebForms
ASP.NET Core
WCF incl. Web Services and Remoting
WPF incl. MVVM and Prism
LINQ and Entity Framework
Live Project Training for Developing Enterprise Application
Live Project using Ntier Arch (.NET5 + EF Core + Angular)
Microservices using .NET Core
Gold Membership
CareerStep IT Program
Client-side UI Technologies
Building Static Web Pages using HTML and CSS
JavaScript and HTML DOM
jQuery, AJAX and JSON
Building Interactive Web Pages using HTML5 and CSS3
BootStrap + Live Examples
AngularJS + Live Project
Angular + Typescript
ReactJS
KnockoutJS
Xamarin
SQL Server + MSBI
SQL Server 2017
Querying Data with Transact-SQL(70-761)
SQL Server Integration Service (SSIS)
SQL Server Reporting Service (SSRS)
SQL Service Analysis Service (SSAS)
Cloud Computing / Azure / AWS
AZ-900: Microsoft Azure Fundamentals
Azure Suite (AZ-104+AZ-204+AZ-305+ AZ-500)
AZ-104: Microsoft Azure Administrator
AZ-204: Developing Solutions for Microsoft Azure
AZ-305: Microsoft Azure Architect Technologies and Design
DP-203: Data Engineering on Microsoft Azure
Amazon Web Services (AWS)
DevOps Expert
AZ-400: Microsoft Azure DevOps
Docker by Sandeep Soni
Kubernetes by Sandeep Soni
Docker & Kubernetes by Rahul Rampurkar
IaC Using Terraform
Powershell
Microsoft Power Platform
Microsoft Power Platform
Data Analytics using PowerBI (DA-100)
Testing Tools
Manual Testing
Selenium Testing with Java(Live Training)
Others
Python Programming
C and Data Structure
Core Java
OOPs and C++
Advance Java
Complete Azure Training
Pricing
Videos
Testimonials
Azure Certification
Contact Us
Login
Login or Register
×
Sign In
Register
Forgot Password?
How did you find us
WhatsApp
YouTube
LinkedIn
Facebook
Telegram
Twitter
Google
Referred by Friend
Refresh
Input symbols
By clicking Register, you accept to the
terms and conditions
and that you have read our
privacy policy.
Recover Password
×
Submit
Enquiry Now
Where did you come to know about us
WhatsApp
YouTube
LinkedIn
Facebook
LinkedIn Ad
Email
Twitter
Google
Referred
Other
Refresh
Input symbols
Interface
Interview Questions and Answer
1. 1.Interface contains what type of variables?
Options:
a. public, private, default
b. public, protected, private
c. default, protected, static
d. public, default, static
Reveal Answer
2. 2. 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); } }
Options:
a. 0
b. 2
c. 4
d. None of the mentioned
Reveal Answer
3. 3.What is the output of this program? interface calculate { void cal(int item); } class displayA implements calculate { int x; public void cal(int item) { x = item * item; } } class displayB implements calculate { int x; public void cal(int item) { x = item / item; } } class interfaces { public static void main(String args[]) { displayA arr1 = new displayA; displayB arr2 = new displayB; arr1.x = 0; arr2.x = 0; arr1.cal(2); arr2.cal(2); System.out.print(arr1.x + " " + arr2.x); } }
Options:
a. 0 0
b. 2 2
c. 4 1
d. 1 4
Reveal Answer
4. 4. What is the output of this program? interface calculate { int VAR = 0; void cal(int item); } class display implements calculate { int x; public void cal(int item) { if (item<2) x = VAR; else x = item * item; } } class interfaces { public static void main(String args[]) { display[] arr=new display[3]; for(int i=0;i<3;i++) arr[i]=new display(); arr[0].cal(0); arr[1].cal(1); arr[2].cal(2); System.out.print(arr[0].x+" " + arr[1].x + " " + arr[2].x); } }
Options:
a. 0 1 2
b. 0 2 4
c. 0 0 4
d. 0 1 4
Reveal Answer
5. 5.what will be the output of the program? public class Foo { public static void main(String[] args) { try { return; } finally { System.out.println( "Finally" ); } } }
Options:
a. Finally
b. Compilation fails.
c. The code runs with no output.
d. An exception is thrown at runtime.
Reveal Answer
6. 6. 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");
Options:
a. finished
b. Exception
c. Compilation fails.
d. Arithmetic Exception
Reveal Answer
7. 7. 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 */ } }
Options:
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.
Reveal Answer
8. 8.at will be the output of the program? public class X { public static void main(String [] args) { try { badMethod(); System.out.print("A"); } catch (RuntimeException ex) /* Line 10 */ { System.out.print("B"); } catch (Exception ex1) { System.out.print("C"); } finally { System.out.print("D"); } System.out.print("E"); } public static void badMethod() { throw new RuntimeException(); } }
Options:
a. BD
b. BCD
c. BDE
d. BCDE
Reveal Answer
9. 9. program on to throw a new user define exception class x { public static void exception() { System.out.print(“throw”); throw new RuntimeException(); } public static void main(String args[]){ try { System.out.print(“hello”); exception(); } catch(Exception ex) { System.out.print(“caught”); } finally { System.out.print(“this is finally block”); } System.out.print(“end”); } }
Options:
a. hellothrow Exception caught
b. compile error
c. hellothrow caught finally after
d. runtime error
Reveal Answer
10. 10.given program is used to write contents in a file if no file found using exception handling to control the code. class y { public static void main(String args[]) { FileOutputStream out=null; try { out=new FileOutputStream(“test.text”); out.write(“abc”); } catch(Exception e) { System.out.println(“Exception”); } finally { out.close(); } } }
Options:
a. compiler error
b. Exception caughtfinally
c. its prints “abc”
d. it returns value count value in a file in a file
Reveal Answer
11. 11.given program is used to handle the code by throwing a user defined exception public class Test{ public static void myMethod() throws Exception { try{ throw new exception(); } finally{ System.out.print(“finally”); } } public static void main(String args[]){ try { myMethod(); } catch(Exception e) { System.out.println(“Exception”); } System.out.print(“finally”); } }
Options:
a. finally
b. exception
c. finally exception
d. compiler error
Reveal Answer
12. 12.What will be the output of this code public class Myprogram { public static void myprog() { throw new RuntimeException(); } public static void main(String args[]) { try { System.out.print(“hello”); myprog(); System.out.println(“try”); } finally { System.out.println(“finally”); } } }
Options:
a. hello finally
b. compile error
c. hello finally try
d. finally try hellothrow
Reveal Answer
13. 13. Given program to display a message by using try catch block. Predict the output for the generated code. class x { public static void main() { try { method(); System.out.print(“p”); } catch(Exception e) { System.out.println(“n”); } finally { System.out.println(“n”); } System.out.println(“p”); public static void method() { } } }
Options:
a. pnp
b. pnnp
c. npp
d. npn
Reveal Answer
14. 14.display the console message by handling the code. class Deccansoft { public static void main() { try { System.out.println(“hello”); } finally { System.out.println(“this is final”); } } }
Options:
a. hello
b. hello this is final
c. this is final
d. exception
Reveal Answer
15. 15.Find the output for this code. class Deccansoft { public static void main(String args[]) { try { return; } finally { System.out.println(“finally”); } } }
Options:
a. finally
b. it displays nothing
c. compiler error
Reveal Answer
16. 16.Given code is used to cloning the messages. Find output for this public class Deccansoft { public static void main(String args[]) { try { return; } finally { try { System.out.println("finally"); } catch(Exception e) { throw new RuntimeException("catch with in finally"); } finally { Deccansoft dc = new Deccansoft(); try { dc.clone(); } catch (CloneNotSupportedException ex) { System.out.println("this is clone"); } } } } }
Options:
a. finally this is clone
b. catch with in finally, this is clone
c. finally, catch with in finally
d. this is clone
Reveal Answer
17. 17.program to handle the logical exception class Deccansoft { public static void main (String args[]) { try { int x=0; int y=5/x; } catch (Exception e) { System.out.println(“Exception”); } catch(ArithematicException ae) { System.out.print(“this is arithematic exception”); } System.out.println(“finished”); } }
Options:
a. Finished
b. Exception
c. Compiler error
d. this is arithematic exception
Reveal Answer
18. 18.Given program is used to handle the thread to prevent deadLock. Find the output for this code? class Deccansoft { public static void main(String args[]) { final StringBuffer a=new StringBuffer(); final StringBuffer b=new StringBuffer(); new Thread(); { public void run() { System.out.println(a.append(“a”)); synchronized(b) { System.out.println(“b”); } } Thread.start(); new Thread() { public void run() { System.out.println(b.appnd(“c”); synchronized(a) { System.out.println(a.appendf(“d”)); } } } thread.start(); } }
Options:
a. accbad
b. abbcad
c. cddacb
d. Indeterminate output
Reveal Answer
19. 19.Program to throw the StringIndexOutOfBoundsException. class Deccansoft { void method() { try { String str=”hello”; char ch=str.charAt(5); } catch(StringIndexOutOfBoundsException sie) { System.out.println(“check weather index is in range or not”); throw sie; } } } class New { Deccansoft dc=new Deccansoft(); try { dc.method(); } catch(StringIndexOutOfBoundsException sie) { System.out.println(“caught exception”); } } }
Options:
a. check weather index is in range or not caught exception
b. compile error
c. check weather index is in range or not
d. caught exception
Reveal Answer
20. 20.A program that throws the NullPointerException. Class Deccansoft { static void demo() { try { System.out.println(“demo”); throw new NullPointerException(“Exception data”); } catch(NullPointerException ne) { System.out.println(ne) } } } class NewDemo { public static void main(String args[]) { Deccansoft.demo(); } }
Options:
a. demo Exception data
b. demo
c. ne
d. Exception data
Reveal Answer
21. 21. program that throws IOException. Class Deccansoft { private String name; void accept() { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.print(“enter name”); name=br.readline(); } void display() { System.out.println(name); } } class New { public static void main(String args[]) { Deccansoft dc =new Deccansoft(); dc.accept(); dc.display();
Options:
a. it will ask user to print his name
b. IOException
c. NullPointerException
d. ArrayIndexOutOfBounds Exception
Reveal Answer
22. 22. Given program is used to create a file and write contents in the file. public class Excptions { void first() throws FileNotFoundException{ second(); } void second() throws FileNotFoundException{ thrid(); } void thrid() throws FileNotFoundException { FileInputStream fin=new FileInputStream("deccansoft.txt"); } } class NewExcep { public static void main(String[] args)throws FileNotFoundException { Excptions t=new Excptions(); t.first(); } }
Options:
a. Exception occurs
b. compiler error
c. a file created
d. no output
Reveal Answer
23. 23.Exception Handling with method overriding. class Parent { void msg() { System.out.print(“parent”); } } class Child extends Parent { void msg() throws IOException { System.out.println(“child”); } public static void main(String args[]) { Parent p=new Parent(); p.msg(); } }
Options:
a. parent
b. child
c. parent child
d. compiler error
Reveal Answer
Packages
Gold Membership
Microsoft Azure Suite &Suite Plus
Azure DevOps Expert &Expert Plus
MS.NET Foundation For Beginners
MS.NET Full Stack Developer
UI / Web Development
SQL Server & MSBI Tools
Software Testing
Resources
Blog
Deccansoft
AzureA2Z
Wall of Fame
On-Job Tech Support
About
About BestDotNetTraining
About Trainer
Testimonials
FAQ
Other links
About Us
Contact Us
Leave us a feedback
Sitemap
Privacy Policy
Terms & Conditions
Proudly Powered by