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
Essentials of Object-Oriented Programming
Interview Questions and Answer
1. 1.program om same method call using different operation? class one { int one(int x){ return x*x; } } class two extends one { int one(int x) { return x*x*x*; } } class { two ref=new one(); ref.one(5); }
Options:
a. Incompatible types
b. 25
c. 125
d. 25 125
Reveal Answer
2. 2.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
3. 3.check weather the static value can be modified or not. class Test { int a() { static int i=0; i++; return i; } Test t=new Test(); int j=test.a(); System.out.print(i); }
Options:
a. Illegal start of expression
b. 0
c. 1
d. 2
Reveal Answer
4. 4.write a program for assigning Integer value to boolean. int x=10; double y=10.5; boolean b=(x=y); System.out.print(b);
Options:
a. true
b. false
c. compilation error
d. exception
Reveal Answer
5. 5. Write a program to pass the values as arguments and accepting it. class A { final int res(int a, int b) { System.out.println(a+""+b); return 0; } class B extends A { int res(int a, int b) { System.out.println(a+""+b); return 1; } class Test { public static void main(String args[]) { B b=new B(); } System.out.print(b.res(1,2)); }
Options:
a. compile error
b. 1 2
c. 1
d. 2
Reveal Answer
6. class Exc { public static void main(String x[]) { try { System.out.println(“hello”); } catch(Exception e){ System.out.println(“try”); } finally { System.out.print(“Deccansoft”); }
Options:
a. hello Deccansoft
b. hello try Deccansoft
c. try Deccansoft
d. hello try
Reveal Answer
7. 7. A program on displaying sum of two numbers class x { public static void main(String ar[]){ int a=3,b=4; System.out.print(a+b); System.out.print(“ ”+a+b+” “); } }
Options:
a. 7 7
b. 34 7
c. 7 34
d. 34 34
Reveal Answer
8. 8.program for printing loop statement class Test { public static void main(String ar[]){ for(int i=0;i<=5;i++) { System.out.print(i); } System.out. print(i); }
Options:
a. compiler error
b. 0 1 2 3 4 5 6
c. 0 1 2 3 4 5 5
d. 1 2 3 4 5 6 6
Reveal Answer
9. 9.write a program to accept the data from out side of class. class Test{ int x=5; Test(int x){ this.x=x; } static void access() { System.out.print(x); } } class x { Test obj=new Test(55); Test.access();}
Options:
a. 55
b. 5
c. compile error
d. run-time error
Reveal Answer
10. 10.write a program to access the data from outside of the another class class x { private int x; void modify(int a) { x=a; x++; } void access() { System.out.print(x); System.out.print(a); System.out.print(x); } } class samp { x xy =new x(); s.modify(10); s.access(); } }
Options:
a. 10 10
b. compile-error
c. 11 11
d. 10 11
Reveal Answer
11. 11.What is the default value of type char?
Options:
a. null
b. space
c. 0
d. false
Reveal Answer
12. 12.Program on calling a method from static block accessing the data. class Test { Static { Test t=new Test(); t.talk(); } public static void main(String args[]){ Test y=new Test(); y.name; y.age; } String name=”abc”; private int age=20; void talk(){ System.out.println(name+” “+age); }
Options:
a. abc 20 null 0
b. null 0 abc 20
c. abc 20 abc 20
d. compiler error
Reveal Answer
13. 13.program to create an object and it returns true if objects are equal otherwise display a message. class Test { public static void main(String args[]){ Object o=new Object() { boolean equal(Object obj) { return true; } } System.out.print(“nikhil”); }
Options:
a. returns true
b. nikhil
c. exception
d. compilation error
Reveal Answer
14. 14.Write a program on inheritance and check weather the given object is instance of a class or not? class A { } class B extends A { } class C extends A { } class X { A a1=new B(); if(a1 instanceof B) System.out.println(“I'm Class B”); else if(a1 instanceof A) System.out.println(“I'm Class A”); else if(a1 instanceof C) System.out.println(“I'm Class C”); else System.out.print(“no match”); }
Options:
a. I'm Class A
b. I'm Class B
c. I'm Class C
d. no match
Reveal Answer
15. 15.write a program on inheritance where by creating an object and initialize data in it ? Class Test{ final int res(int a, int b) { return 0; } } Class Test1 extends Test { final int res(int a, int b) { return 1; } } Class x { Test1 tes=new Test1(); System.out.println(tes.res(0,1)); }
Options:
a. 0
b. 1
c. compile error
d. exception
Reveal Answer
16. 16.program to print the elements in a command line arguments. public class Part2 { public static void main(String[] args) { System.out.println("hello"+args[0]); } }
Options:
a. hello
b. hello null
c. hello 0
d. compile error
Reveal Answer
17. 17.program to count the value for given n number interface Count { short counter=0; void countMe(); } class Test implements Count { public static void main(String args[]){ Test t= new Test(); t.countMe(); } public void countMe() { for(int x=6;x>counter; x--,++counter); { System.out.print(counter); } }
Options:
a. 0 1 2
b. 1 2 3
c. 0 1 2 3
d. compiler error
Reveal Answer
18. 18.write a program on inheritance and access the sub class from the super class. class A { A(int x){ } class B extends A{ } class Test{ public static void main(String args[]){ A a= new B(); System.out.print(“completed”); } }
Options:
a. completed
b. compile error
c. exception
d. displays empty
Reveal Answer
19. 19.write a program to create a objects and swap the objects and store the values and display result . class Test { public static void main(String args[]) { Test t, t1, t2; t1=new Test(); t2=new res(t1); t=new Test(); t1=t2; } static Test res(Test result) { result=new Test(); return result; } }
Options:
a. 1
b. 0
c. 2
d. 3
Reveal Answer
20. 20.write a program to accept the string by using constructor with similar parameters. class x { int i=0; public x(String s) 20.write a program to accept the string by using constructor with similar parameters. class x { int i=0; public x(String s) { i=1; } class y extends x { public y(String s) { i=2; } public static void main(String args[]) { y z=new y(“hello”); System.out.println(y.i); } } a)0 b)1 c)2 d)compiler error Answer: D { i=1; } class y extends x { public y(String s) { i=2; } public static void main(String args[]) { y z=new y(“hello”); System.out.println(y.i); } }
Options:
a. 0
b. 1
c. 2
d. compiler error
Reveal Answer
21. 21.what will be the output for this code? Class Deccansoft { void a() { System.out.print(“Deccansoft”); } public static void main(String args[]) { new Deccansoft(); } }
Options:
a. class Deccansoft
b. compile error
c. exception
d. no output
Reveal Answer
22. 22. write a program to display the details of a person public class Deccansoft { private String name="raju"; private int age=30; Deccansoft talk() { age=this.age; return age; } deccansoft talk(String name) { this.name=name; return name; } } class y { public static void main(String[] args) { Deccansoft ob=new Deccansoft(); System.out.println(ob.talk()); System.out.println(ob.talk("hello")); } }
Options:
a. hello 30
b. raju 30
c. compile error at class y
d. compile error at line 6
Reveal Answer
23. 23.Access a person details in another class by creating object to it. class deccansoft { private int age=20; private String name=”hello”; deccansoft talk() { age=this.age; return age; } deccansoft talk(String name) { this.name=name; return name; } class Another { public static void main(String args[]) { Deccansoft dc=new Deccansoft(); System.out.println(dc.name); System.out.print(ds.talk(“welcome”)); System.out.println(dc.age);
Options:
a. hello 20
b. welcome 20
c. compiler error
d. 20
Reveal Answer
24. 24.Access a person details in another class by creating object to it. class deccansoft { private int age=20; private String name=”hello”; int talk() { this.age=age; return age; } int talk(String name) { this.name=name; System.out.print(name); return name; } class Another { public static void main(String args[]) { Deccansoft dc=new Deccansoft(); System.out.println(dc.name); System.out.println(dc.age); } }
Options:
a. hello 20
b. 20
c. hello
d. compiler error
Reveal Answer
25. 25. Implementing abstract methods of my interface. interface hello { interface app { void hippo(String a, app p); } } class a implements hello.app { @Override public void hippo(String a, app p) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }
Options:
a. compiler error
b. Not supported yet
c. exception
d. can't determine
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