Encapsulation - refers to the hiding of data and methods within an objects. and also protects data from corruption.
- easier to modify programs since one object type is modified at a time.
Friday, June 25, 2010
Abstraction in java
Abstraction refers to the ability to make a class abstract in OOP.
An abstract class is one that cannot be instantiated. All other functionality of the class still exists, and its fields, methods, and constructors are all accessed in the same manner. You just cannot create an instance of the abstract class.
An abstract class is one that cannot be instantiated. All other functionality of the class still exists, and its fields, methods, and constructors are all accessed in the same manner. You just cannot create an instance of the abstract class.
Labels:
abstract in java,
Abstraction in java,
abstration
Thursday, June 24, 2010
Creating an object in java program
Creating an object in java program
class Puppy{
public Puppy(String name){
// This constructor has one parameter, name.
System.out.println("Your Name is :" + name );
}public static void main(String []args){
// Following statement would create an object myPuppy
Puppy myPuppy = new Puppy( "Jaypee" );
}
}sample output:
Your Name is : Jaypee
Creating an Object in Java
Creating an Object:
As mentioned previously a class provides the blueprints for objects. So basically an object is created from a class. In java the new key word is used to create new objects.There are three steps when creating an object from a class:
- Declaration . A variable declaration with a variable name with an object type.
- Instantiation . The 'new' key word is used to create the object.
- Initialization . The 'new' keyword is followed by a call o a constructor. This call initializes the new object.
Labels:
creating object in java,
java object,
object in java
Objects and Classes in Java
Objects - represent "things: from the real world.
the objects is made up of attributes and methods.
Attributes - define the object.
methods - describes the mechanism that actually perform its tasks.
Classes - describes a group or collection of objects with common properties and also define a type of objects
Example of classes:
- employee
- car
-chair
the objects is made up of attributes and methods.
Attributes - define the object.
methods - describes the mechanism that actually perform its tasks.
Classes - describes a group or collection of objects with common properties and also define a type of objects
Example of classes:
- employee
- car
-chair
Flowcharting Problem and Solution
This is a sample flowchart and algorithm solution to the problem compute two numbers and get the sum.
this a good steps to solve the problem in programming.
this a good steps to solve the problem in programming.
Subscribe to:
Posts (Atom)
