Tuesday, May 19, 2015

Java Learning , if you know C : Part 7 Some Concepts


Classes : It is like skeleton from which we make our objects

Objects : They are real-world examples.

Instance  : The object which is currently in memory .

Inheritance :

Using one class methods and varibales in other classes.

In java , you cannot have two classes inhertied into one unlike C++. Only one class be inherited. But multi-level inheritance is supported .

Ex :

Class A

Class B

Class C  inherits Class A and Class B    This is not supported in Java. Multiple Inheritance

but

Class B inheirts Class A
Class C inherits Class B   this is supported.

Syntax in java

Class A {}

Class B extends Class A{}            Simple :)


Polymorphism : Changing of existing methods to suite new object requirement.

In Java we use

Method Overloading : Number and types of arguments will change
Method Overriding :


Abstraction : This is what common across some objects/class.  Like car, ship , bus  , they all transport people.

So we can define new class having the common characteristic and reuse(inherit) it .

Encapsulation : This is main reason of defining class. To have variables and thier methods bind together of a class. The process of binding variables and methods to an abstract class.

Information hiding : Simply means which variables/methods you want to expose.
Use of Public and private

-----------------------------------------------------------------------------------------------------------

Class Modifiers :
 For Access : Public  > can be accessed from any classes.
                      Private >
                      Protected
                      default
For App method :
                      Final
                      Abstract
                      static

 Member Variable
                   Acess : private, public,protected,default
                   App : final , static

Member Method : Will focus only on those which are defined for Varibales

-----------------------------------------------------------------------------------------------------------------


No comments:

Post a Comment