Skip to main content


Showing posts with the label Java Programming

Java Basic Syntax

When we consider a Java program, it can be defined as a collection of objects that communicate via invoking each other's methods. Let us now briefly look into what do class, object, methods and instance variables mean. ·          Object - Objects have states and behaviours. Example: A dog has states-colour, name, and breed as well as behaviours -wagging, barking, and eating. An object is an instance of a class. ·          Class - A class can be defined as a template/blue print that describes the behaviours/states that object of its type support. ·          Methods - A method is basically behaviour. A class can contain many methods. It is in methods where the logics are written, data is manipulated and all the actions are executed. ·          Instance Variables - Each object has its unique set of instance variables. An object's state is created by the values assigned to these instance variables. First Java Program: Let us look at a simple code that would print the words Hel

Java Environment Setup

Before proceeding further, it is important to set up the Java environment correctly. Install the JDK downloaded from the Oracle website. It is available free of cost. Once you installed Java on your machine, you would need to set environment variables to point to correct installation directories: Setting up the path for Windows 7/8/8.1/10: Assuming you have installed Java in c:\Program Files (x86)\java\jdk   directory: ·          Right-click on 'Computer' and select 'Properties'. ·          Click ‘Advanced System Settings’ ·          Click on the 'Environment variables' button under the 'Advanced' tab. ·          Now, add ( remember ADD not Replace ) the 'Path' variable so that it also contains the path to the Java executable. Example, if the path is currently set to 'C:\WINDOWS\SYSTEM32', then change your path to 'C:\WINDOWS\SYSTEM32;c:\Program Files (x86)\java\jdk\bin'. Setting up the path for Windows 2000/XP: Assuming you have

Features of Java

Ø   Object Oriented: In Java, everything is an Object. Java can be easily extended since it is based on the Object model. Ø   Platform independent: Unlike many other programming languages including C and C++, when Java is compiled, it is not compiled into platform specific machine, rather into platform independent byte code. This byte code is distributed over the web and interpreted by virtual Machine (JVM) on whichever platform it is being run. Ø   Simple: Java is designed to be easy to learn. If you understand the basic concept of OOP, Java would be easy to master. Ø   Secure: With Java's secure feature, it enables to develop virus-free, tamper-free systems. Authentication techniques are based on public-key encryption. Ø   Robust: Java makes an effort to eliminate error prone situations by emphasizing mainly on compile time error checking and runtime checking. Ø   Architectural-neutral: Java compiler generates an architecture-neutral object file format, which makes the compi