Get Adobe Flash player

Monday, December 26, 2011

Structure of a Java Program

Structure of Java Program ...

A Java program with two classes

class Room {float length;float breadth;void getdata(float a, float b) { length=a; breadth=b; }}class RoomArea{public static void main(String args[]) { float area; Room room1 = new Room();//Create an object room1 from the class Room room1.getdata(15,20); area=room1.length * room1.breadth; System.out.println("Area = "+area); }}...

A Simple Java Program

class Sample{public static void main(String args[]){System.out.println("Java is pure OOP");}}Now Understanding the programThe first line class Sampledeclare a class, which is an object oriented construct. Java is a pure object oriented language so everything in java must be placed inside a class. class is a keyword and used to declare a new class definition. Sample is a java identifier that specifies the name of the class to be defined.The Braces { & }In java every class definition begins with an open brace “{“ and end with a matching closing brace “}” just like in C++. But 1 thing to remember , in C++ class definition ends with a semicolon “;” but in java it’s not.For example In C++class SampleCPPclass{//Body of the class};//Semicolone requiredIn Javaclass SampleCPPclass{//Body of the...

Tuesday, November 15, 2011

Life Cycle of a java program

The figure below explains the lifecycle of a Java Program. In words, the figure can be explained as:A Java program is written using either a Text Editor like Textpad or an IDE like Eclipse and is saved as a .java file. (Program.java) The .java file is then compiled using Java compiler and a .class file is obtained from it. (Program.class) The .class file is now portable and can be used to run this Java program in any platform. Class file (Program.class) is interpreted by the JVM installed on a particular platform. JVM is part of the JRE software...

Web Browsers

A web browser is a software application for retrieving, presenting, and traversing information resources on the World Wide Web. An information resource is identified by a Uniform Resource Identifier (URI) and may be a web page, image, video, or other piece of content. Hyperlinks present in resources enable users easily to navigate their browsers to related resources. A web browser can also be defined as an application software or program designed to enable users to access, retrieve and view documents and other resources on the Internet. Example of Web browsers : HotJava Netscape Navigator Internet Explorer HotJava :        HotJava (later called HotJava Browser to distinguish...

Java as an Internet Language

Java is an object oriented language and a very simple language. Because it has no space for complexities. At the initial stages of its development it was called as OAK. OAK was designed for handling set up boxes and devices. But later new features were added to it and it was renamed as Java. Java became a general purpose language that had many features to support it as the internet language. Few of the features that favors it to be an internet language are:Cross Platform Compatibility:  The java source files (java files with .java extension) after compilation generates the bytecode (the files with .class extension) which is further converted into the machine code by the interpreter. The byte code once generated can execute on any machine having a JVM. Every operating system has...

Features of Java

Simple:        The syntax for Java is like a cleanup version of the syntax of C++. Their is no need for header file pointer arithmetic structures, union , operator overloading and virtual base class and so on...        Another aspect for being simple is being small. Java enable the construction of software that can run stand alone in a small machine. The size of the basic interpreter and class support is only 40 KB (approx). Object oriented:        Java is a object oriented language. Almost everything in java is an object. All program code and data reside within class and objects. The objects model in java is simple and easy to extend.Distributed :        Java is designed as a distributed ;language...

Difference between Java & C++

Java is a true object oriented language while C++ is basically C with object-oriented extension. That is what exactly the increment operator ++ indicates. C++ has maintained backward compatibility with C. It is therefore possible to write and old style C program and run it successfully in C++. Java appears to be simile to C++ when we consider only the "extension" part of C++. However, some object-oriented features of C++ make the C++ code extremely difficult to follow and maintain.&nb...

Difference between Java & C

Java i s lot like C but the major difference between Java and C is that Java is an object-oriented langugae and has mechanism to define classes and objects. To build a simple and safe language, the Java team did not include some of the C features in Java. Java does not include the C unique statement keywords sizeof, and typedef. Java does not contain the data types struct and union. Java does not define the type modifiers keywords auto,extern,register,signed, and unsigned.  Java does not support an explicit pointer type. Java does not have a preprocessor and therefore we can not use #define, #include, and #ifdef statements. Java requires that the function with no arguments must be declared with empty parenthesis and not with the void keyword as done in C. Java adds new operators...

Saturday, November 12, 2011

Basic Concept of Object Oriented Programming

Objects & Classes: Objects are the basic runtime entities in an Object-Orients System. They may represent a person, a bank, a car etc… Each object has its own properties and behavior.  For example if we chose a CAR as an object then its properties will be number of wheels, height, width, length, body material etc, and its behavior will be run, turn left, turn right, turn backward etc..                                                                                                                                                      ...

Page 1 of 612345Next