1.
What is OOPS?
OOPS stands for Object
Oriented Programming system
In OOPS the programs
are considered as a collection of objects.
Each object is nothing but an
instance of a class.
Object is the mother
class of java
2. Write basic concepts of OOPS?
Following are the concepts of OOPS and are as follows:
2. Write basic concepts of OOPS?
Following are the concepts of OOPS and are as follows:
1.
Abstraction.
2.
Encapsulation.
3.
Inheritance.
4.
Polymorphism.
3. What is a class?
A class is a collection
of objects.
A class is a collection
of variables,methods,properties and
object
It is the blueprint
that describes the details of an object.
Declaration
of class
Class classname
{
//variables
//properties
//methods
}
Where class is a keywords
and classname is user defined that means you can give any name to class
Example:
Class A
{
//
}
4. What is an object?
Object is an instance
of a class, and it has its own state, behavior and identity.
Example: if computer
is a class then keyboard, mouse are the objects
Declaration of object:
Classname
instance name=new Classname ();
Example:
A a1=new A (); //A is classname, a1
is object name, New is a keyword and used to allocate memory
a1.show
();
// call or invoke the method to execute the program
(a1 is the object name and show () is method name)
a1.x=5;
// used to initialize
the variable (a1 is the object name and x is the variable name)
Uses of object:
It is used to call or
invoke the method to execute the program
It is used to initialize
the variable
5. What is Encapsulation?
Encapsulation means wrapping or hiding of data
in a class and controlling its access.
Encapsulation is implemented using private, package-private and
protected access modifier.
For Example: Mobiles and owners...
all the functions of mobiles are encapsulated with the owners.
No one else can access it...
all the functions of mobiles are encapsulated with the owners.
No one else can access it...
Advantages: Security
6. What is Polymorphism?
Polymorphism is
nothing but assigning behavior or value in a child class to something that was
already declared in the parent class.
Polymorphism takes more
than one form
7. What is Inheritance?
Inheritance is a concept where one class shares the structure and behavior defined in another class.
7. What is Inheritance?
Inheritance is a concept where one class shares the structure and behavior defined in another class.
If inheritance applied
on one class is called Single Inheritance, and if it depends on multiple
classes, then it is called multiple Inheritance.
Advantages: reusability,
extensibility
Abstraction means providing important or necessary features
without giving internal or background details.
Abstraction is implemented
in Java using interface and abstract class..
For Example: - When user is using Mobile application he
doesn't know internal working of all functions like calling, send Sms but he
can call or send sms without knowing internal details. His main aim is using the mobile phone not to know about
internal structure
9. What are
the advantages of OOPS concepts?
1.
Simplicity: OOPS programming objects model real world
objects, so the complexity is reduced (you know that object is real time entity
so it’s very simple to use).
2.
Extensibility: Adding new features or responding to
changing operating environments can be solved by introducing a few new objects
and modifying some existing ones (Inheritance).
3.
Security: it supports encapsulation so security level
is very high
4.
Reusability: Objects can be reused in different programs
using inheritance
No comments:
Post a Comment