Saturday, October 25, 2008

JAVA PROGRAM STRUCTURE




Java program may contain many classes of which only one class
defines a main methos. Classes contain data members and
methods that operate on the data members of the class.Methods
may contain data type declarations and executable statements.
To Write a Java program we first define classes and then put
them together.A Java program may contain one or more sections

Documentation Section


The documentation section comprises a set of comment lines giving
the name of the program,the author and other details,which the programmer
would like to refer to at a later stage.Comments must explain why
and what of classes and how of algorithms.This would greatly help
in maintaining the program.In the addition to the two styles of comments
discussed earlier, Java also uses a third style of comments/**....*/
known as documntation comment.This form of comment is used for generating
documentation automatically.

Package Statement


The first statement allowed in a Java file is a package statement.This
statement declares a package name and informs the compiler that the
classes defined here belong to this package.Example
Package student;

Import Statements


The next thing after a package statement may be a number of
import statement This is similar to the #include statement in C. Example
import student.test;
This statement instructs the interpreter to load the test class
contained in the package student.Using import statements,we can
have access to classes that are part of other named packages.

Interface Statement


An interface is like a class but incudes a group of method declarations.
This is also an optional section of a Java program.These classes are used
to map the objects of real-world problems.The number of classes used depends
on the complexity of the problem.

Main Method Class


Since every Java stand-alone program requires a main methos as
its starting point,this class is the essential part of a Java
program.A simple Java program may contain only this part.The
main method creates objects of various classes and
establishes communications between them.On reaching the end of main,
the program termiates and the control passes back to the operating system.

Sunday, October 19, 2008

C++ information


What is C++?


Released in 1985, C++ is an object-oriented programming
language created by Bjarne Stroustrup. C++ maintains
almost all aspects of the C language, while simplifying
memory management and adding several features -
including a new datatype known as a class (you will
learn more about these later) - to allow object-oriented
programming. C++ maintains the features of C which allowed
for low-level memory access but also gives the programmer
new tools to simplify memory management.

What is C++ used for?


C++ is a powerful general-purpose programming language.
It can be used to create small programs or large
applications.It can be used to make CGI scripts or
console-only DOS programs.C++ allows you to create programs
to do almost anything you need to do. The creator of C++,
Bjarne Stroustrup, has put together
a partial list of applications written in C++.

What is Object-Oriented Programming?


Object oriented programming is essentially building a
program around self-contained collections of data
and code to modify that data; this programming model
is in contrast to a model that uses function that act
on data scattered throughout a program. Object-oriented
programming (or coding, as programming is commonly referred
to) is an organizational style, but it helps programmers
create reusable code because the code to do a specific thing
is entirely contained within a single section of code, and
to use the code to perform tasks - for instance,creating a
menu - involves using only a small number of functions
to access the internals of the class. Think of it as a black box
that can be easily carried from place to place, and that performs
complex actions simply at the press of a button: for instance, a
microwave lets you heat food for a specified time limit - say, two
minutes - by typing in the time and pressing the heat button. You
do not need to know how the microwave operates or why the physics
works. In the same way that self-contained appliances simplify life
for the consumer, object-oriented programming simplifies the transfer
of source code from one program to another program by encapsulating
it - putting it all in one place.

What do you need to program in C or C++?


In order to make usable programs in C or C++, you will need
a compiler. A compiler converts source code - the actual
instructions typed by the programmer - into an executable
file. Numerous compilers are available for C and C++.
Listed on the sidebar are several pages with information
on specific compilers. For beginners, Bloodshed Dev,
which uses a Windows interface, is a free and
easy-to-use compiler.

How do you learn C++?


No special knowledge is needed to learn C++, and if you
are an independent learner, you can probably learn C++
from online tutorials or from books. There are plenty
of free tutorials online, including the one on this site
- one which requires no prior programming experience.
You can also pick out programming books from our
recommendations.

While reading a tutorial or a book, it is often helpful
to type - not copy and paste (even if you can!) - the
code into the compiler and run it. Typing it yourself
will help you to get used to the typical typing errors
that cause problems and it will force you to pay attention
to the details of programming syntax. Typing your program
will also familiarize you with the general structure of
programs and with the use of common commands. After
running an example program - and after making certain
that you understand how it works - you should experiment
with it: play with the program and test your own ideas.
By seeing which modifications cause problems and which
sections of the code are most important to the function
of the program, you should learn quite a bit about programming.

Saturday, October 18, 2008

Can U guess

main()
{
int i;
for(i=0;i<10;i++)
printf("%d",i++,i,++i)
}

Evaluate this one.

Friday, October 17, 2008