Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what are the oops concept in java explain with real time
examples

Answer Posted / srikanth acharya

The OOPs concepts are:-
Object:-An object can be considered a "thing" that can
perform a set of related activities. The set of activities
that the object performs defines the object's behavior. For
example, the hand can grip something or a Student (object)
can give the name or address.

Class:- A class is simply a representation of a type of
object. It is the blueprint/ plan/ template that describe
the details of an object. A class is the blueprint from
which the individual objects are created. Class is composed
of three things: a name, attributes, and operations.

public class Student
{
}
According to the sample given below we can say that the
student object, named objectStudent, has created out of the
Student class.

Student objectStudent = new Student();

Encapsulation or information hiding:-The encapsulation is
the inclusion within a program object of all the resources
need for the object to function - basically, the methods
and the data. In OOP the encapsulation is mainly achieved
by creating classes, the classes expose public methods and
properties. The class is kind of a container or capsule or
a cell, which encapsulate the set of methods, attribute and
properties to provide its indented functionalities to other
classes. In that sense, encapsulation also allows a class
to change its internal implementation without hurting the
overall functioning of the system. That idea of
encapsulation is to hide how a class does it but to allow
requesting what to do.

There are several other ways that an encapsulation can be
used, as an example we can take the usage of an interface.
The interface can be used to hide the information of an
implemented class.

IStudent myStudent = new LocalStudent();
IStudent myStudent = new ForeignStudent();

Abstraction and Generalization:-Abstraction is an emphasis
on the idea, qualities and properties rather than the
particulars (a suppression of detail). The importance of
abstraction is derived from its ability to hide irrelevant
details and from the use of names to reference objects.
Abstraction is essential in the construction of programs.
It places the emphasis on what an object is or does rather
than how it is represented or how it works. Thus, it is the
primary means of managing complexity in large programs.
Abstraction and generalization are often used together.
Abstracts are generalized through parameterization to
provide greater utility. In parameterization, one or more
parts of an entity are replaced with a name which is new to
the entity. The name is used as a parameter. When the
parameterized abstract is invoked, it is invoked with a
binding of the parameter to an argument.
Abstract classes, which declared with the abstract keyword,
cannot be instantiated. It can only be used as a super-
class for other classes that extend the abstract class.
Abstract class is the concept and implementation gets
completed when it is being realized by a subclass. In
addition to this a class can inherit only from one abstract
class (but a class may implement many interfaces) and must
override all its abstract methods/ properties and may
override virtual methods/ properties.

Inheritance:-Ability of a new class to be created, from an
existing class by extending it, is called inheritance.

public class Exception
{
}

public class IOException extends Exception
{
}

Polymorphism:-Polymorphisms is a generic term that
means 'many shapes'. More precisely Polymorphisms means the
ability to request that the same operations be performed by
a wide range of different types of things.

The method overloading is the ability to define several
methods all with the same name.

public class XYZ
{
public void Error(Exception e)
{
// Implementation goes here
}

public bool Error(Exception e, string message)
{
// Implementation goes here
}
The operator overloading (less commonly known as ad-hoc
polymorphisms) is a specific case of polymorphisms in which
some or all of operators like +, - or == are treated as
polymorphic functions and as such have different behaviors
depending on the types of its arguments.

Is This Answer Correct ?    2 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to print nodes of a Binary tree?

2244


Explain method local inner classes ?

1027


when to use ArrayList and when to use HashMap in webApplication.

4691


what is enumset?

1108


Can a string be null?

973


What is the difference between Java1.4 and Java1.5

2302


What does the “static” keyword mean?

1096


What is outofmemoryerror in java?

1020


What is a stringbuffer?

961


What is polymorphism in java? What are the kinds of polymorphism?

1064


What is a java lambda expression?

1042


What is the final keyword in java?

1417


Can a static class have a constructor?

998


Is there any way to find whether software installed in the system is registered by just providing the .exe file? I have tried the following code but its just displaying the directory structure in the registry. Here the code : package com.msi.intaller; import java.util.Iterator; import ca.beq.util.win32.registry.RegistryKey; import ca.beq.util.win32.registry.RootKey; public class RegistryFinder { public static void main(String... args) throws Exception { RegistryKey.initialize(RegistryFinder.class.getResource("jRe gistryKey.dll").getFile()); RegistryKey key = new RegistryKey(RootKey.HKLM, "Software\\ODBC"); for (Iterator subkeys = key.subkeys(); subkeys.hasNext();) { RegistryKey subkey = subkeys.next(); System.out.println(subkey.getName()); // You need to check here if there's anything which matches "Mozilla FireFox". } } }

1798


What are the benefits of immutable objects?

997