Showing posts with label oops. Show all posts
Showing posts with label oops. Show all posts

Saturday, 24 October 2015

OBJECT ORIENTED PROGRAMMING


OBJECT ORIENTED PROGRAMMING

In this a main program is divided into small objects depending on the problem. Functions of object are linked with object using message passing. Data and functions of each individual object act like a single unit.

Data gets more importance than function in the program.

Each object controls its own data.

Data hiding is possible in OOP which prevents illegal access of function from outside of it.

More data and function can be added to program if required. It follows Bottom-up approach for program design. Popular Example: c++,java

 

From the above para we can infer that an object is an important part over here.So what an object is?

It has many definitions.Lets get to the basic one thatis  “it is a real world entity”.It could be a desk,T.V, bicycle etc.

These objects share two characteristic:

1.       State

2.       Behaviour

AN example would be :

A desktop lamp which has 2 states – (on and off) and 2 behavior (turn on && turn off).

An object stores its state in fields (variables) and exposes its behaviour through methods(functions).

Methods operate on an objects internal state and serve as the primary mechanism for object-object communication.

 

Features of OOP:

1.class

2.object

3.encapsulation

4.abstraction

5.inheritance

6.message passing

7.polymorphism.

Lets discuss each in detail.

1.       Class

Can be said as  a blueprint to create objects.This blueprint has attributes and methods that all created object share.

A class can be a person,place or thing.Fundamentally it encapsulates state andbehavior

Syntax of class:

         class  class_name{

                properties(variables);

                Action(methods);

}

 

Variables inside a class are called instance variables(Things that object knows about itself).

Variables inside a method are called method variables.

Methods are things an object can do.

When we create a class think about the objects that  will be created from that class type.
Example program for class explanation:



 
 
The below program describes the importance of objects .
 

This is the output:






Thursday, 17 September 2015

JAVA INTRODUCTION

Java---A platform independent programming language.

platform independent--

we can write java programs once and run it anywhere.Here JVM comes into picture. JVM(java virtual machine) it is used to run java programs and it is platform dependent which means every operating system have their own compatible JVM's.

Introduction:

Java as u all know was developed in Jan 1991 by James Gosling et.al(Chris wrath,ed frank,mike Sheridan,Patrick naughton).This language was system independent and was initially called  Oak and renamed to java later on.

Symbol for java language-- cup and saucer.

Sun formally announced Java at sun world conference in 1995.

On Jan 23 1996 , JDK 1.0 version was released.

Java is an OOP(Object Oriented Programming)Language.

what is OOP?
main program is divided into small objects depending on the problem.
it follows Bottom up process for program design.

Features of  OOP:

1.Class
2.Object
3.Encapsulation
4.Abstraction
5.Inheritance
6.Message Passing

we'll these features in detail in my later post for now lets move on to
1.software installation
2.setting java class path
3. and our first java program

1.Software Installation

So we can download  JDK software from  http://www.oracle.com/technetwork/java/javase/downloads/index.html

Every Language requires an editor where we can write our programs and a compiler which converts it into machine language.Many Vendors have provided the combination of both in the form of Integrated Development Environment(IDE).And to name a few we have Eclipse IDE and Netbeans IDE.


Based on the version of your OS you can download these softwares. The url mentioned above will allow u install Netbeans IDE version 8 along with Java 8.

Follow the steps mentioned there.After downloading it u can better start with ur first java program

Now for those who prefer manual editor go to the above url and install java compatible with you OS.After that we have to set the java path.


To set the java classpath.Browse the folder where java got installed

"C:\Program Files\Java\jdk7.0\bin" ---copy this path using ctrl+c

Right Click MyComputer --go to properties--there u'll see an Advanced Tab--Click it n then open Environment Variables.

A new Screen opens up showing u the
user defined variable
system variable

In both places Click New--Type variable name as classpath/JAVA_HOME then paste the copied path in the next field.save it

Now to know if java got installed or not
Open Cmd Prompt--type javac

then relevant details gets displayed else u'll get an error saying "cmd not supported"
In Next Post we'll learn setting Java path in detail.