Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Thursday, November 24, 2011

Learn Java programming tutorial lesson 8 - Inheritance

What is inheritance?

Inheritance is the ability of objects in java to inherit properties and methods from other objects. When an object inherits from another object it can add its own properties and methods. The object that is being inherited from is called the parent or base class and the class that is inheriting from the parent is called the child or derived class.

How to use inheritance

We will first create a parent class called Person. We will then create a child class called Student. Then we will create a program to use the Student class. The following is a Person class which has a variable...

Learn Java programming tutorial lesson 7 - Object-Oriented Programming(OOP)


What is Object-Oriented Programming?

Object oriented programming or OOP is a way of writing programs using objects. An object is a data structure in memory that has attributes and methods. The attributes of an object are the same as variables and the methods of an object are the same as functions or procedures.
The reason for using objects instead of the old procedural method of programming is because objects group the variables and methods about something together instead of keeping them all apart as in procedural programming...

Learn Java programming tutorial lesson 6 - Arrays


What is an array

An array is group of variables that is given only one name. Each variable that makes up the array is given a number instead of a name which makes it easier to work with using loops among other things.

Declaring an array

Declaring an array is the same as declaring a normal variable except that you must put a set of square brackets after the variable type. Here is an example...

Learn Java programming tutorial lesson 5 - Data input and type conversions

Until now we have set the values of variables in the programs. Now we will learn how to get input from the user so that our programs are a bit more interesting and useful.

Reading single characters

To read a single character from the user you must use the System.in.read() method. This will return and integer value of the key pressed which must be converted to a character. We use (char) in front of System.in...

Learn Java programming tutorial lesson 4 - Loops

What is a loop?

A loop is a way of repeating lines of code. If you want to for example print Hello on the screen 10 times then you can either use System.out.println 10 times or you can put 1 System.out.println in a loop that runs 10 times which takes a lot less lines of code.

For loop

The for loop goes from a number you give it to a second number you give it. It uses a loop counter variable to store the current loop number. Here is the format for a for loop:
for (set starting value; end condition; increment loop variable)
You first set the loop counter variable to...

Learn Java programming tutorial lesson 3 - Decisions

What are decisions?

A decision is a way of allowing a program to choose which code to run. If a condition is met then one section of code will be run and if it is not then another section will be run.

The if decision structure

The if statement evaluates a condition and if the result is true then it runs...

Learn Java programming tutorial lesson 2 - Variables and constants


What is a variable

Variables are places in the computer's memory where you store the data for a program. Each variable is given a unique name which you refer to it with.

Variable types

There are 3 different types of data that can be stored in variables. The first type is the numeric type which stores numbers. There are 2 types of numeric variables which are integer and real. Integers are whole numbers such as 1,2,3,...

Learn Java programming tutorial lesson 1 - First Program


What is Java?

Java is an object-oriented programming language which was developed by Sun Microsystems. Java programs are platform independant which means they can be run on any operating system with any type of processor as long as the Java interpreter is available on that system.

What you will need

You will need the Java software development kit from Sun's Java site. Follow the instructions on Sun's website to install it. Make sure that you add the java bin directory to your PATH environment variable.
...
Setec Institute || Group : SH6 | | Name : Kim Chanthy. Powered by Blogger.
 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Hot Sonakshi Sinha, Car Price in India