Introduction to Java
● Java is a high-level programming language used for utilities, games,
and business applications.
● Java is fast, secure, and reliable. It is used in laptops, cell phones,
data centres, internet, etc..
● Java is popular because:
○ Of the concept of WORA [Write once, run anywhere]. This
means that once a java program is written, it can be accessed
on other computers as long as they have a JRE (Java runtime
environment) installed.
○ Programs are easy to write and debug.
● Java was released by Sun Microsystems in 1995. James Gosling,
Patrick Sherida, James Naughton were credited with designing Java.
● Some well known Java IDEs [integrated development environment)
are BlueJ, Eclipse, Java Netbeans and IntelliJ.
● Features of Object oriented programming:
○ Modern Approach to Programming.
○ Concept implemented using objects.
○ Objects communicate with each other using functions
○ Divides the program into objects.
○ Eg. C++, Python, Java
● Class: group of objects sharing common properties.
○ Consist of: Data Members and Member functions.
○ ‘Building Blocks of Java’, ‘blueprint’.
● Objects: It is an identifiable entity with some behaviours and
characteristics.
● Basic Element of object oriented programming. Objects are called
instances of their class. Properties:
○ Identity: Name by which it is recognised.
○ State: Object can be in any state. Eg., on, off.
○ Behaviour: What the object is capable of.
○ Objects interact by sending messages to each other.
● To create a small program:
○ BlueJ>Project>New Project>Enter project name>Create>New
class>Enter Class Name>Ok>Double Click class icon.
● To execute a program:
○ Right Click on program>select method>method call
box>ok>output on terminal window.
● In “public class HelloWorld”
○ ‘Public’ is the access modifier. [Others:Private, protected, default]
and ‘class’ is used to declare a class.
● In “public void main()”
○ Public is access modifier
○ Void: Declares nothing will be returned from the method.
● Comments: Start: /* End: */
● Line Comments: //
● In ‘System.out.println(“HelloWorld”);
○ ‘System’ is a Java utility class. Out is an object of that class and
print is a method of that class which is used to send any string
to the console/terminal. Ln represents that ”Hello World” will
be printed on a new line.
● Keywords are the words that convey a special meaning to the
language compiler.
● A ‘double’ value provides accuracy up to 15 digits.
● Boolean size is 1 bit. Logical or boolean values.
● Characters that cannot be typed are called ‘non graphic characters’
and are represented by escape sequences.
● Variables represent named storage locations whose values can be
manipulated during the program.
● Not equal to: !=
● Flow:
○ Code flows from the 1st to the last line.
○ The control gets terminated after the last line of code.
○ Normal flow of program
○ Takes place by Default
● Conditional: if, switch, loops.
● If: bi-directional branching.