IGNOU CS-74 B1/U1 – Basic of Java

Intended Readers

This documentation is mainly focused to those readers who are aware of C/C++ programming language as well as Object oriented programming. I am preparing this document as reference to my students who are conducting courses at IGNOU and Purbhanchal university. The document will be written mostly bulleted points so that it will be easier to read as note.


  • Introduction to Java
  • History of Java
  • Object Oriented Programming in Java
  • Java Buzzwords (features)
  • Java Virtual Machine (JVM)
  • Structure of Java Program
  • Compiling and Running Java
  • IDEs for Java


– According to Oracle (in its documentation): “Java Technology is both a programming language and platform.” [1]

  • Java is among the popular high-level language which inherit feature of C and C++ and along with improved features.
  • Java can be used in wide range of development environment including: Desktop, Mobile, Enterprise, Web, Embedded in devices [3]

History of Java

  • “The Green Project” Began in 1991
  • Original language name: Oak
  • Name change to Java
  • First public release in 1995
  • Write Once, Run anywhere

Object Oriented Programming in Java

  • Java is some time considered as Pure Object oriented Programming as Every Java program must contain at least one Class.
  • Object oriented programming (OOP) is a programming technique or paradigm, which is focused on object rather than operation or function unlike procedural oriented programming [2].
  • An Object is a instance of a class.
  • Class is a Secondary data type like structure in C which binds (encapsulate):
    • Attributes (Data fields)
    • methods (Operations/Behaviors)
  • why Object Oriented Programming (OOP)? [4]
    • Modularization
      • Problem can be decomposed into smaller sub problems that can be solved separately and result can be merged to get final result.
      • For example: In Java there many in-built class libraries, say you need to use mathematical operation and on date, then you can use Math and Date classes in your program.
    • Abstraction
      • You don’t have to know detail of how any Class or method is constructed to use it.
      • For example: you can use Math Class and use different mathematical operations like random, abs etc without knowing how they are implemented.
    • Encapsulation – Information Hidding

      • Attributes are methods are bind together, so that complexity can be hiddne from Users and security can be easily imposed.
    • Composability
      • multiple Classes and Interfaces allow to freely combine modules to produce new systems.
    • Hierarchy and resue

      • existing class can be reused to cread customized sub class so that incremental development can be done from small and simple to more complex modules.
    • Continuity
      • Changes and maintenane in only a few modules does not affect the entire architecture.
      • For example: if mathematical function is to be change in Java, it can be done easily in Math Class without effecting other classes like Date, String etc.
  • For Example: take Vehical as Class then Car and Bike will be two different sub classes with shared basic features of vehicle and some specialized attributes and operations.Figure: ClassVehicle.png

Java Buzzwords (features) [1]

  • Simple
    • Assumes most of that students studied C/C++ in School/University, so Java is very similer to these programming languages. Java is even easier than C/C++ for programming.
  • Object oriented

    • Every thing in Java is considered as Object.
  • Distributed
    • RMI, Corba and EJB are some of the key components, which help Java to be a distributed programming language.
  • Multithreaded
    • Java itself is built in multithreaded Architecture. Thread class and Runnable interface helps programmers to develop multi-threaded programming easily in Java.
  • Dynamic
    • Java Run time Machine (JVM) maintains many run time information.
    • Libraries are dynamically linked on runtime.
  • Architecture neutral
    • Java’s bytecode can run in any architecture including x86 x64, PowerPC, and more with the help of Java Run time Machine (JVM).
  • Portable
    • Java program can be run in any platform with the help of Java Run time Machine (JVM).
    • when compiled Java progrem creates bytecode which can be easily migrated to any architecture or platform.
  • High Performance

    • JIT Compiler improves performance with cache
    • Robust (relible)
    • Type checking, garbase collection and exception handling helps Java to be Robost.
  • Secure
    • strongly typed
    • no pointer access
    • byte code verifier
    • Seperation of OS and Application with JVM

How Java works

  • Write Java program in plain text files with .java extension.
  • Compile source files with javac ( output: byte code .class file)
  • Run Java luncher tool to run .class file in Java Virtual machine.
  • Java VM is availabe in many different operating systems, so the same .class file can be runn in Ms. Windows, Solaris, Linux, Mac OSx etc.
Java Working

Working of Java

(Image Source: http://docs.oracle.com/javase/tutorial/figures/getStarted/helloWorld.gif)

Java Platform

  • A platform is the hardware or software environment for program to be executed.
  • Most platform can be described as a combination of the OS and underlying hardware. [1]
  • Java Platform has two component
    • The Java Virtual Machine
    • The Java application Interface (API)
  • Java Virtual Machine [8]

    • Java Virtual Machine can be explained as any one of three different things
      • The abstract Specification
      • A concrete implemenation, or
      • a runtime instance.
    • “Java Virtual Machine has a clear mission in life: to run one Java Application”. [8]
    • When a Java application starts, a runtime instance is spawn or born. When the application completes, the instance dies.
    • If you run 2 different application in Java Virtual Machine (JVM) then each application runs in its own VM without interfaring each other. – Architecture of Java Virtual Machine (JVM)
    • Java Virtual machine (JVM) is defined as a virtual machine instance in terms of subsystems, memory areas, data types and instructions.
    • These components describe an abstract inner architectur for the abstract Java Virtual Machine.
    • It directly impacts on external behavior of implementations.
    • The specification defines the required behavior of any Java virtual machine implementation in terms of these abstract components and their interactions.
    • Figure below illustrates different components of Java Virtual Machine.
JVM Components

Components of JVM

( Image source: http://www.artima.com/insidejvm/ed2/images/fig5-1.gif )

For nore detail of Java Virtual Machine internals, refer to no. 8 URL.

  • Java API Libraries

    • Java system includes a number of libraries of utility classes and methods of use to develpers in creating multi-platform applications. Some of the libraries are:
      • java.lang (imported automatically)
      • java.io
      • java.util
      • java.awt
      • java.net

First program

Create a file named HelloWorld.java in any text editors like notepad, textmate, vi, gedit etc.


package np.com.shiba.java.lecture1;

import java.jang.*;

public class HelloWorld {

public static void main(String[] args){

System.out.println(“Welcome to shiba.com.np Java SE Documentation”);





  • np.com.shiba.java.lecture1 is a package name. Package in Java is a way of implementing namespace, which will be discuss later in detail.
  • import java.lang.* will import list of all classes and interface in java.lang package so that we can access each class in the package without provide full package name space.
  • public class HelloWord { defines class with main method which can be accessed easily from outside package.
  • In a Java application, the program start by invoking the main() method.
  • the main method must be public so that Java Virtual Machine can access it from outside class.
  • The main method should be static so that class instance creation is not needed.
  • main method should be void so data no data is returned.
  • Finally, a String array is passed as argument so that command line argument can be passed to Java Application.

Development tools

  • The Java SE Development Kit includes the runtime, compiler, and other tools, including:
    • javac – a command line compiler
    • java – a command line runtime
    • jar – the packager
    • javadoc – the documentation builder
  • Compiling and Running
    • javac HelloWorld.java
    • java HelloWorld

    Available Editors and IDEs for Java


  • JavaGUI javaJDBC JavaNetworkProgramming rmi

Sample Questions for BE Computer, Purganchal University


Collection of Sample Questions for BCA and BE Computer.

Java Important Questions for BCA and BE Computer Java

Old Questions for BCA Computer Purbanchal university:



More detail can be found in following links for additional reading.

[1] http://docs.oracle.com/javase/tutorial/getStarted/intro/definition.html (Date: 3-12-2013)

[2] http://en.wikipedia.org/wiki/Object-oriented_programming (Date: 3-12-2013)

[3] http://www.ibm.com/developerworks/java/tutorials/j-introtojava1/section2.html (Date: 3-12-2013)

[4] http://www.felixgers.de/teaching/oop/oop_intro.html (Date: 3-12-2013)

[5] http://www.blackwasp.co.uk/ObjectOrientedConcepts.aspx (Date: 3-12-2013)

[6] http://docs.oracle.com/javase/tutorial/

[7] http://www.oracle.com/technetwork/java/langenv-140151.html(Date: 3-12-2013)

[8] http://www.artima.com/insidejvm/ed2/jvm.html (Date: 3-12-2013)


Recent Posts
Recent Comments
    Updates on Recent activieies