Sunday, 17 May 2015

CONCEPT OF OBJECT – INTRODUCING CLASSES- INTRODUCTION JAVA

1.1 OBJECT ORIENTED PROGRAMMING
An object oriented programming (OOPS) is a modular approach, which allows data to be applied within stipulated program area. It also provides the reusability feature to develop productive logic, which means to give more emphasis on data.
1.2 FEATURES OF OBJECT ORIENTED PROGRAMMING
i.                    It gives stress on the data items rather than functions.
ii.                  It makes the complete program / problem simpler by dividing it into number of objects.
iii.                The object can be used as a bridge to have data flow from one function to another.
iv.                We can easily modify the data without any change in the function.
1.3 BASIC ELEMENTS OF OOP (PRINCIPALS OF OOP
  1. Object  2. Classes  3. Data Abstraction  4. Encapsulation  5. Data hiding  6. Inheritance  7. Polymorphism
1.4 OBJECT :- Object is a unique entity, which contains data and function(Characteristics and behaviour) together in an object oriented programming OOPs Language.
i.           It is visible.   
ii.        It can be defined and described easily .
1.5 CLASSES:- Class is a set of different objects. Each object of the class possesses same attributes and behaviour defined within the same class. Hence class is also termed as object factory.
1.6 ENCAPSULATON:- The system of wrapping data and function into single unit( called class) in known as encapsulation.
1.7 DATA HIDING:- Such insulation of data , which can not be accessed directly outside class premises although they are available in the same program, is known as data hiding.
1.8 DATA ABSTRACTION:- Abstraction refers to the act of representing essential features without including background details.
1.9 INHERITANCE:- Inheritance is the process by which object of one class can link & share some common properties of object from another class.
 * Process of acquiring  properties of an existing class is called inheritance.
1.10 USE OF INHERITANCE:- (i) No need to repeat the code ii) reusability of the class.
(ii) It in transitive in nature.
1.11 REUSABLITY:-It is the process of adding some additional features to a class without modifying its contents.
1.12 POLYMORPHISM; - Allows two or more class to respond to the same message in different ways, this means we can use the same name for a method in two different class or same class. It also means that the user can send the same message to two different classes and still get the correct response.
* The process of representing one thing in many forms is called polymorphism.
1.13.  What is a state and behaviour of an object? Explain with examples.
Object share two characteristics: they all have state and behaviour. For example, your dog has state (name, colour, and breed) and behaviour (barking, fetching and wagging tail.)
            Real world object have state and behaviour. Software objects state is implemented through member data and behaviour is implemented through member function /methods.
1.14 Why is data considered safe when encapsulated?
This keeps the code and the data, safe from outside interference and misuse. It prevents the data from being accessed by any other code defined outside the wrapper.


1.15 How do object encapsulate state and behaviour?
State and behaviour of object are interweaved. They are said to encapsulate state and behaviour. e.g. a car object has characteristics like number of wheels seats etc. its state is represented as halted, moving or stationary and its behaviour is, it can move, stop, blow horn etc,. Now all these things are wrapped up together in the form of car. Thus we can say the object encapsulates their state and behaviour as their state and behaviour are interlinked, they cannot exist separately.
1.16 RUNTIME  ERROR:- It occurs due to wrong logic of the program. It occurs at the time of execution.
1.17 SYNTAX ERROR; - It occurs when the syntax of the program is not correct .It occurs at the time of compilation.
1.18 JAVA – A high level programming language developed by Sun Microsystems. It was invented by James Gosling and others in 1994.Java were originally called OAK and were developed as a part of Green Project at the sun company. It was designed for handheld devices and set-top boxes.
1.19 FEATURES OF JAVA;-
-          Java is an object oriented programming language.
-          It can access data from a local system as well as from a network.
-          Java program is written within a class. The variable and function are declared and defined within the class.
-          There are two types of java program- Applets and Application programs. Applets are the programs which run on web-browser. Application programs are the general programs like any other programming language.
-          Java           is a case sensitive language. It distinguishes the upper case and lower case letters.
1.20 BYTE CODE AND JVM
-          Java is a high level language and the program written in HLL is compiled and then converted to an intermediate language called byte code.
-          When this Byte code is to run on any other system, an interpreter known as Java Virtual Machine is needed which translates the byte code to machine language. JVM acts as a virtual processor which processes the byte code to machine code instructions for various platforms. That is why it is called Java Virtual Machine.
1.21 Why is java architecture neutral?
Java architecture is neutral because java byte code is not associated with any particular hardware platform. It can be executed on any machine with a java interpreter.
1.22 Difference between .java & .class
Java source code (files with a .java extension) are compiled into a format called byte code (files with a .class extension), which can then be executed by a java interpreter.
Where does java run?
Java virtual machine can run on: Windows 95, Windows NT, Solaries 2.3(or higher), PowerMacs, and java station, set top Box etc

1.23 COMMENTS IN JAVA; - A comment can be expressed in a program by following two styles:
i)                    // for single line comment.
E.g. // this is a remark
ii) /*… */: for multiple line comments. As it have beginning marks and ending marks.
e.g. /* this comment can proceed in different lines*/                                                 [2005]

important question
1.  Name any two OOP'S Principles. [2005]
  Encapsulation and Abstraction
2.Define encapsulation.                     [2006]
ENCAPSULATON:- The system of wrapping data and function into single unit( called class) in known as encapsulation. It mean that wrapping up of data and methods together as a single unit.
3.Explain the term object using an example.[2006
OBJECT :- Object is a unique entity, which contains data and function(Characteristics and behaviour) together in an object oriented programming OOPs Language.
i.           It is visible.  
ii.        It can be defined and described easily

4. Define a variable.                          [2006]
VARIBLES: -  A variable is a named memory location, which contains a value. The value of variable can be changed depending upon the circumstances and problem in the program.
int a=5;
here ‘a’ is a variable of integer type and hold the value 5
5. Mention any two attributes required for class declaration.                                                [2008]
Ans  1.Characteristic and behavior.

2..Member data and Member function

No comments:

Post a Comment