ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
explain oops concepts with examples?
 Question Submitted By :: Ramanareddy333
I also faced this Question!!     Rank Answer Posted By  
 
  Re: explain oops concepts with examples?
Answer
# 1
There are three types of oops in java.
1.Encapsulation:Encapsulation is mechanism,that binds
together data and code its manipulates.
Ex:suppose we are writing one bean.we declaring two private
variables.we are providing setters and getters methods of
two variables.These variables are accessed in that class.
2.Inheritance:To acquire the base class properties into
derived class.
Ex:class A{
 m1(){
 System.out.println("m1 method");
 }
}
class B extends A{
 m2(){
  System.out.println("m2 method");
 }
 public static void main(String args[]){
   B b = new B();
   System.out.println(b.m1);
   System.out.println(b.m2);
 }
}
O/p is:m1 method
       m2 method.
Polymorphism:one Interface to be used for a general class of
actions.
There are two types of polymorphisms.
1.Compile-time polymorphism:what object will be assigned to
the present variable.This will be evaluated at compile time.
This is known as compile-time polymorphism.
2.Run-time polymorphism:what object will be assigned to the
present variable.This will be evaluated at runtime depending
on condition.This is known as Run-time polymorphism.
 
Is This Answer Correct ?    53 Yes 15 No
Dara
 
  Re: explain oops concepts with examples?
Answer
# 2
OOPS Concepts:
  1) Encapsulation: Wrapping up of data and methods in to a
single unit is called as encapsulation.

  2) Abstraction: It Supports Abstarction

  3) Inheritence:Process of Aquiring properties from one
object to another without changes.

 4) Polymorphism:Process of aquiring properies from one
object to anotherwith changes.

                poly=many

               morphism=forms

5) Message Passing:message passing is possible from one
object to another.

6) Robust and Secure: every object is strong one.         
every object is secure one with their access specifiers.
 
Is This Answer Correct ?    36 Yes 22 No
K.rajasekhar Naidu
 
 
 
  Re: explain oops concepts with examples?
Answer
# 3
oops means object oriented programming. which contains only 
objects&methods.java is one of the object oriented 
programming language.. but it is not a 100% oop... Because 
java uses premitive datatypes..... 
oops contains  some features:
1:encapsulation
2:inheritance
3:polymorphism
 
Is This Answer Correct ?    29 Yes 15 No
Srinivas
 
  Re: explain oops concepts with examples?
Answer
# 4
abstraction
encapsulation
inheritence
polymorphism
 
Is This Answer Correct ?    21 Yes 31 No
Ravikiran
 
  Re: explain oops concepts with examples?
Answer
# 5
OOP is Nothing but Object Oriented Programming.
In OOPs concept is implimented in our real life systems.
OOPs have following features
1. Object   - Instance of class
2. Class    - Blue print of Object 
3. encapsulation  - Protecting our data
4. polymorphism   - Different behaviors at diff. instances
5. abstraction    - Hidding our irrelavance data
6. inheritence    - one property of object is aquring to 
another property of object
 
Simple Ex.

Please assume u standing near a car. How to impliments our 
OOPs concept for this scenario ?

Simple,
car is a object b'coz it having more functions.
car is a class b'coz it contain more parts and features 
inside.
car is a Encapsulation B'coz it protected some unwanted 
parts or functions to user
car is a Polymorphism b'coz it have different speed as 
display in same speedometer
car is a Abstraction b'coz it hidding more parts by coverig 
such as engine,disel tank
car is a Inheritance b'coz one car is a property of more 
people. i mean your car is driving bu you, your friend and 
your relatives.
 
Is This Answer Correct ?    65 Yes 10 No
Arun From India In Madurai
 
  Re: explain oops concepts with examples?
Answer
# 6
Abstraction: giving only important things hiding unnecessary
things.
data hiding: we can get by using private keyword
encapsulation: abstraction+data hiding(security)
polymorphism: flexibility
inheritance: reusability
 
Is This Answer Correct ?    15 Yes 7 No
Reddy
 
  Re: explain oops concepts with examples?
Answer
# 7
dataabstraction:it is giving only important things hiding 
unnecessary things
 
encapsulation : it is data hiding under  wrapper class
  
  inheritance :it is reusebility code 
  example : parent propert belongs to child
  
  polymorpism: it is flexibility when output depends upon 
no  of input
 in this we have overloading 




overloading means it contains  same data type and 
different  parameters
 
Is This Answer Correct ?    8 Yes 7 No
Srinu
 
  Re: explain oops concepts with examples?
Answer
# 8
OOP is Nothing but Object Oriented Programming.
In OOPs concept is implimented in our real life systems.
OOPs have following features
1. Object   - Instance of class
2. Class    - Blue print of Object 
3. encapsulation  - Protecting our data
4. polymorphism   - Different behaviors at diff. instances
5. abstraction    - Hidding our irrelavance data
6. inheritence    - one property of object is aquring to 
another property of object
7.Message Passing:message passing is possible from one
object to another
8.Robust and Secure: every object is strong one.         
every object is secure one with their access specifiers.
 
Is This Answer Correct ?    14 Yes 3 No
Nagesh
 
  Re: explain oops concepts with examples?
Answer
# 9
OOP is Nothing but Object Oriented Programming.
In OOPs concept is implimented in our real life systems.
OOPs have following features
1. Object   - Instance of class
2. Class    - Blue print of Object 
3. encapsulation  - Protecting our data
4. polymorphism   - Different behaviors at diff. instances
5. abstraction    - Hidding our irrelavance data
6. inheritence    - one property of object is aquring to 
another property of object
 
Simple Ex.

Please assume u standing near a car. How to impliments our 
OOPs concept for this scenario ?

Simple,
car is a object b'coz it having more functions.
car is a class b'coz it contain more parts and features 
inside.
car is a Encapsulation B'coz it protected some unwanted 
parts or functions to user
car is a Polymorphism b'coz it have different speed as 
display in same speedometer
car is a Abstraction b'coz it hidding more parts by coverig 
such as engine,disel tank
car is a Inheritance b'coz one car is a property of more 
people. i mean your car is driving bu you, your friend and 
your relatives.
 
Is This Answer Correct ?    11 Yes 2 No
Vikram Chandra
 
  Re: explain oops concepts with examples?
Answer
# 10
Encapsulation is the procedure of covering up of data and
functions into a single unit. Encapsulation (also
information hiding) consists of separating the external
aspects of an object which are accessible to other objects,
from the internal implementation details of the object,
which are hidden from other objects.

A process, encapsulation means the act of enclosing one or
more items within a (physical or logical) container (Class)
 
Is This Answer Correct ?    9 Yes 3 No
J
 
  Re: explain oops concepts with examples?
Answer
# 11
OOP is Nothing but Object Oriented Programming.
In OOPs concept is implimented in our real life systems.
OOPs have following features
1. Object   - Instance of class
2. Class    - Blue print of Object 
3. encapsulation  - Protecting our data
4. polymorphism   - Different behaviors at diff. instances
5. abstraction    - Hidding our irrelavance data
6. inheritence    - one property of object is aquring to 
another property of object
 
Simple Ex.

Please assume u standing near a car. How to impliments our 
OOPs concept for this scenario ?

Simple,
car is a object b'coz it having more functions.
car is a class b'coz it contain more parts and features 
inside.
car is a Encapsulation B'coz it protected some unwanted 
parts or functions to user
car is a Polymorphism b'coz it have different speed as 
display in same speedometer
car is a Abstraction b'coz it hidding more parts by coverig 
such as engine,disel tank
car is a Inheritance b'coz one car is a property of more 
people. i mean your car is driving bu you, your friend and 
your relatives.
 
Is This Answer Correct ?    4 Yes 4 No
Manoj Donga
 
  Re: explain oops concepts with examples?
Answer
# 12
Abstraction: is hiding irrelevant of data

object: Instance of class
class: Blue print of object

polymorphism: different function with different parameter

interface:is semantically  related to abstract
members,members by public default.

Encapsulation: capsule  with data and object
inheritance: Base class  derived from another class
 
Is This Answer Correct ?    5 Yes 4 No
Nirmal Kumar
 
  Re: explain oops concepts with examples?
Answer
# 13
OOPS Concepts are mainly 4

1.Abstraction
2.Encapsulation
3.Inheritance
4.Polymorphisam

Abstraction:- Hidding non-essential features and showing the
essential features
(or)
Hidding unnecessary data from the users details, is called
abstraction.

Real Time example: TV Remote Button
in that number format and power buttons and other buttons
there just we are seeing the buttons, we don't see the
button circuits .i.e buttons circuits and wirings all are
hidden. so i think its good example.

Encapsulation:
Writing Operations and methods stored in a single
class. This is Called Encapsulation

Real Time Example: Medical Capsuals
i.e one drug is stored in buttom layer and another drug is
stored in Upper layer these two layers are combined in
single capsual.

Inheritance:
The New Class is Existing from Old Class, i.e SubClass is
Existing from Super Class.

Real Time Example:
Father and Son Relationship

Polymorphism:
Sinle Form behaving differently in different
Situations.

Example:-
Person
Person in Home act is husband/son,
in Office acts Employer.
in Public Good Citizen.
 
Is This Answer Correct ?    13 Yes 4 No
Vijay
 
  Re: explain oops concepts with examples?
Answer
# 14
abstraction:it shows important data and hide the unwanted data
polymorphism:it shows different behaviors at different instances
Encapsulation:it provides security for the data
inheritance:the process of acquiring the properties of one
object to another object
 
Is This Answer Correct ?    4 Yes 0 No
Srinivas
 
  Re: explain oops concepts with examples?
Answer
# 15
OOP is  Object Oriented Programming.
In OOPs concept is implimented in our real life systems.
OOPs have following features
1. Object         - Instance of class
2. Class          - Collection of Object(Methods and 
variable) 
3. encapsulation  - Protecting our data by data hiding
                    encapsulation=abstraction+data hiding.
4. polymorphism   - Different behaviors at diff. instances
5. abstraction    - Hidding our irrelavance data and     
showing necessary data to the user.
6. inheritence    - one property of one object is aquring 
by the another object.
 
Simple Ex.

Please assume u standing near a car. How to impliments our 
OOPs concept for this scenario ?

Simple,
A motor bike is a object b'coz it having more functions.
motor bike is a class b'coz it contain more parts and 
features 
inside.
motor bike is a Encapsulation B'coz it protected some 
unwanted 
parts or functions to user
motor bike is a Polymorphism b'coz it have different speed 
as 
display in same speedometer
motor bike is a Abstraction b'coz it hidding more parts by 
coverig 
such as engine,disel tank
motor bike is a Inheritance b'coz one car is a property of 
more 
people. i mean your car is driving bu you, your friend and 
your relatives.
 
Is This Answer Correct ?    5 Yes 1 No
Vaibhav Pathak
 
  Re: explain oops concepts with examples?
Answer
# 16
OOP concepts are mainly 4 parts
such as
1.Abstraction
2.Encapsulation
3.Inheritence
4.Polymorphism

1.Abstraction:which means showing essential features and
hiding non-essential features to the user.

for ex.  yahoo mail...

when you provide the user name and password and click on
submit button..
it will shows comepose,Inbox,Outbox,sentmails...so and so
when you click on compose it will open...but user doesn't
know what are the actions performed internally....
just it is open only....this is essential
user doesn't know internall actions ...this is non-essential
things...

for ex tv remote..
remote is a interface between user and tv..ryt.
which is no.of buttons like 0 to 10 ,on /oof like that
but we dont know inside remote like circuites...
user no need to know..just he is using essential thing is
remote.
so developer of remote has to hide the circuit becz he
doesn't anything abut remote...this is non-essential thing.

2.Encapsulation: means which binds the data and code.
(or) writing operations and methods in single unit (class).

for example:
A car is having multipls parts..like
stering,wheels,engine...etc..which binds together to form a
single object that is car.

In real time we are using for security purpose...
encapsulation = abstraction + data hiding.

3.Inheritance:
        Deriving a new class from the existing class,is
called inheritance

derived(sub class) class is getting all the features from
existing (super class) class and also incorporating some new
features to the sub class.
 
for ex:
class Address
{
String name;
Srting H.no;
String Street name;
}
class LatestAddress extends Address
{
String City;
String State;
String Country;
}
public class Devendra
{
psvm(----)
{
LatestAddress la = new LatestAddress();
//do assignment...as u wish
}
}

here in the above class LatestAddress getting all features
from the Address class.
here in the LatestAddress class is having total 6 properties
3 from inheited from Address class and 3 properties
incorporated.

4.Polymorphism:
poly means many

one form can perform differently in different scenarios.
(or) we can use multiful forms in multiful scenarios we will
get different results in different scenarios.

polymorphism mainly happens in runtime only..i.e in
overriding itself

for example
class A
{
void test()
{
sop("A");
}
void test1()
{
sop("A()");
}
}
class B extends A
{
void test()
{
sop("B");
}
void test1()
{
sop("B()");
}
void another()
{
sop("another()");
}
}
public class Devendra
{
psvm(---)
{
A a1 = new A();
A a2 = new B();
B b = new B();
a1.test();------> A
a1.test1();-----> A()
a2.test();------> A
a2.test1();-----> A()
b.test();-------> B
b.test1();------> B()
b.another();----> another()


If you have any quires pls mail me  at   mdevendra@gmail.com
 
Is This Answer Correct ?    2 Yes 1 No
Devendra.m
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
What is the specification of ?CODEBASE? in an applet?  1
Why do inner class cannot have static declaration except static nested class? Wipro1
What is the difference between C++ & Java? Syntel21
How to validate the request (Eg:user name and password) in session(http session)? not in LDAP server ? Saksoft1
why ,we are using jsp and html.which one is better? Photon1
When you say String is immutable, what do you mean by that? Say I have String s = "Ness" s= s+"Technologies"; What will happen? If the value gets appended, then what is the meaning of immutable here? Ness-Technologies4
what is the difference between Cpp And Java Infosys7
is there any function in java to make the text to blink?  5
What classes of exceptions, caught by a catch clause?  1
What we have to do, when we don't want to implement all methods of an interface?  2
class{ ... ... interface myinterface{ ... ... } abstract class{ .. .. } ... .. .. } is this possible to write "Interface and/ or Abstract class inside a class ? if possible whcich one is possible is only interface? is only abstract? Logica-CMG2
What is finally in exception handling?  6
what is mean by method signature? Satyam5
Can an object?s finalize() method be invoked while it is reachable?  2
What is HashTable?  3
What is the root class for all Java classes?  4
What is clipping?  2
Difference between this(), super()?  8
What is cloneable interface?  5
How to declare unique ArrayList ? RMSI4
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com