You are on page 1of 43

Computer: Computer is an electronic device which is used to perform arithmetical and logical

operations.
Or
A computer is an electronic device which accepts the data as input, processes it, stores it
and gives the output / information.

Data: The collection of raw variables like numbers, characters and alpha numerical is called data.

Or
The collection of facts and figures is called data.

Processing: This will be done inside the central processing unit(CPU).

A 65 1000001
Human Language Human Language Machine Language
Alphabet Decimal/ASCII Binary

Information: The Processed data is called output/Information

DataProcessingStoreInformation
Input Output
Computer: Hardware + Firmware + Software

Hardware: The physical components of the computer which we can see, touch and feel is called
hardware.

Firmware: It is software which increases the performance of hardware.

Software: A set of programs that executes on hardware which does the given task and gives the
result.

Types of Software

Application Software: An application software is one which is used for a specific application, for
example if we develop a software for a gas agency or a supermarket it is used for that purpose
only.
Ex: Ms-Office,Tally…

System Software: Used to maintain the system.


Ex: Antivirus

Operating Systems: An operating system is one which maintains overall functions of a computer
from switch on to switch off.
(or)
An operating system is one which acts like a platform for running other softwares.

Development Software/General Software: Used to develop different varieties of software.


Ex: Languages

Languages: A language is one in which programs must be written to get the acquired result.

Program:
Group of statements arranged in an orderly fashion to get the acquired result is
called a program.
Depending on writing of a program languages are

1. Unstructured languages
2. Structured languages

An unstructured language is one in which every statement in a program contains line


number or label.

Ex:
COBOL – Common Business Oriented Language
BASIC – Beginners All Purpose Symbolic Instruction Code

10 begin
20 let a=30,b=20,c;
30 c=a+b;
40 goto 30:print c
50 end
www.quitebasic.com

A structured language is one in which the statements in a program does not contain any
line number or label.

Ex: C,C++

#include<stdio.h>
#include<conio.h>
main()
{
int a=30,b=20,c;
c=a+b;
printf("c=%d",c);
}

After writing a program we will error check it. Depending on error checking languages are
1. Interpreter based languages: An interpreter-based language is one in which the interpretation
stops wherever the error exists, and it won't proceed for the next statements until and unless we
correct errors in that statement

Ex: BASIC, PYTHON

2. compiler-based languages: A compiler based language is one in which the whole program will
be compiled first and errors are shown last.

Ex: C, C++

3. Pseudo compiler-based languages: A pseudo compiler-based language is one which


Sometimes acts as an interpreter and sometimes as a compiler.

Ex: Visual Basic, Java

Generations of languages
1. The first generation languages, or 1GL, are low-level languages that are machine language.

2. The second-generation languages, or 2GL, are also low-level assembly languages. They are
sometimes used in kernels and hardware drives, but more commonly used for video editing and
video games.

3. The third-generation languages, or 3GL, are high-level languages, such as C, C++, Java,
JavaScript, and Visual Basic.

4. The fourth-generation languages, or 4GL, are languages that consist of statements similar to
statements in a human language. Fourth generation languages are commonly used in database
programming and scripts examples include Perl, PHP, Python, Ruby, and SQL.

5. The fifth-generation languages, or 5GL, are programming languages that contain visual tools
to help develop a program. Examples of fifth generation languages include Mercury, OPS5, and
Prolog.
Basing on paradigm (Syntax) languages are again classified into

1. Procedural or function oriented


2. Object Oriented
3) Object Based
4) Multi Paradigm

Procedure Oriented Programming (POP)


1. Main program is divided into small parts depending on the functions.

2. The Different part of the program connects with each other by parameter passing & using
operating system.

3. Every function contains different data.

4. Functions get more importance than data in program.

5. Most of the functions use global data.

6. Same data may be transfer from one function to another

7. There is no perfect way for data hiding.

8. Functions communicate with other functions maintaining as usual rules.

9. More data or functions cannot be added with program if necessary. For this purpose full
program need to be change.

10. To add new data in program user should be ensure that function allows it.

11. Top down process is followed for program design.

12. Example: Pascal, Fortran,C,Pascal,Cobol


OBJECT ORIENTED PROGRAMMING

History: Developed by Kristen Nygaard and Ole-Johan Dahl in Norway. They were
working on simulations that deal with exploding ships, and realized they could group the
ships into different categories. Each ship type would have its own class, and the class would
generate its unique behavior and data.
 The term "object oriented programming" was first used by Xerox PARC in their Smalltalk
programming language.

 Alan Kay coined the term “object oriented programming” at grad school in 1966 or 1967.

 The First Programming Language to Use Objects was Simula-67

Features
 Class
 Objects
 Methods
 Abstraction
 Encapsulation
 Polymorphism
 Inheritance

Class: Is like a blueprint of an object. A class contains member variables and methods.

Object: Object is an instance of its class. Object is used to access the methods and variables in a
class.
Methods: The operations that an object can perform. Methods define the behavior of an object.

Encapsulation: An information hiding and securing mechanism. It helps in restricting the access
of data from the outside entities it means only the methods in a class can access its member
variables. Encapsulation reduces the system complexity and increases robustness.

Abstraction: provides a way to hide the less essential properties so as to reduce complexity and
increase efficiency
Polymorphism is a way to have more than one form of a method. In polymorphism, we use the
method overloading and method overriding techniques.
Inheritance:Used to reduce the code and reuse the already available code. Here we extend a base
class to a derived class. The derived class then inherits the properties of its base class.
Object Oriented Programming (OOP): Object Oriented programming

1. Main program is divided into small object depending on the problem.

2. Functions of object linked with object using message passing.

3. Data & functions of each individual object act like a single unit.

4. Data gets more importance than functions in program.

5. Each object controls its own data.

6. Data does not possible transfer from one object to another.

7. Data hiding possible in OOP which prevent illegal access of function from outside of it.

8. One object link with other using the message passing.


9. More data or functions can be added with program if necessary. For this purpose full program
need not to be change.

10. Message passing ensure the permission of accessing member of an object from other object.

11. Bottom up process is followed for program design.

12. Example: C++, Java.

Java: Java is a structured, high level, object oriented, pseudo compiler based, platform
independent, generic programming language which is used to develop web applications.Java
was developed at SUN Micro Systems by a team called Green Team

1) James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language
project in June 1991.

2) Originally designed for small, embedded systems in electronic appliances like set-top boxes.

3) Firstly, it was called "Greentalk" by James Gosling and file extension was .gt.

4) After that, it was called Oak and was developed as a part of the Green project.

Why Oak name for java language?


5) Why Oak? Oak is a symbol of strength and choosen as a national tree of many countries like U.S.A.,
France, Germany, Romania etc.
6) In 1995, Oak was renamed as "Java" because it was already a trademark by Oak
Technologies.

Why Java name for java language?

7) Why they choosed java name for java language? The team gathered to choose a new name.
The suggested words were "dynamic", "revolutionary", "Silk", "jolt", "DNA" etc. They wanted
something that reflected the essence of the technology: revolutionary, dynamic, lively, cool,
unique, and easy to spell and fun to say.

According to James Gosling "Java was one of the top choices along with Silk". Since java was
so unique, most of the team members preferred java.

8) Java is an island of Indonesia where first coffee was produced (called java coffee).

9) Notice that Java is just a name not an acronym.

10) Originally developed by James Gosling at Sun Microsystems (which is now a subsidiary of
Oracle Corporation) and released in 1995.

11) In 1995, Time magazine called Java one of the Ten Best Products of 1995.

12) JDK 1.0 released in(January 23, 1996).

Java Version History

Now a day 8 versions of java are released, which is listed below with realizing date.

 JDK Alpha and Beta (1995)

 JDK 1.0 (23rd Jan, 1996)

 JDK 1.1 (19th Feb, 1997)

 J2SE 1.2 (8th Dec, 1998)

 J2SE 1.3 (8th May, 2000)

 J2SE 1.4 (6th Feb, 2002)

 J2SE 5.0 (30th Sep, 2004)

 Java SE 6 (11th Dec, 2006)

 Java SE 7 (28th July, 2011)


 Java SE 8 (18th March, 2014)

Where it is used?
According to Sun, 3 billion devices run java. There are many devices where java is currently
used. Some of them are as follows:

1. Desktop Applications such as acrobat reader, media player, antivirus etc.


2. Web Applications such as irctc.co.in, javatpoint.com etc.
3. Enterprise Applications such as banking applications.
4. Mobile
5. Embedded System
6. Smart Card
7. Robotics
8. Games etc.

Types of Java Applications


There are mainly 4 type of applications that can be created using java:

1) Standalone Application

It is also known as desktop application or window-based application. An application that we


need to install on every machine such as media player, antivirus etc. AWT and Swing are used in
java for creating standalone applications.

2) Web Application

An application that runs on the server side and creates dynamic page, is called web application.
Currently, servlet, jsp, struts, jsf etc. technologies are used for creating web applications in java.

3) Enterprise Application

An application that is distributed in nature, such as banking applications etc. It has the advantage
of high level security, load balancing and clustering. In java, EJB is used for creating enterprise
applications.
4) Mobile Application

An application that is created for mobile devices. Currently Android and Java ME are used for
creating mobile applications.

Features Of Java

There is given many features of java. They are also known as java buzzwords.

1. Simple
2. Object-Oriented
3. Platform independent
4. Secured
5. Robust
6. Architecture neutral
7. Portable
8. Dynamic
9. Interpreted
10. High Performance
11. Multithreaded
12. Distributed

Simple
According to Sun, Java language is simple because:

syntax is based on C++ (so easier for programmers to learn it after C++).

removed many confusing and/or rarely-used features e.g., explicit pointers, operator overloading
etc.

No need to remove unreferenced objects because there is Automatic Garbage Collection in java.

Object-oriented

Object-oriented means we organize our software as a combination of different types of objects that
incorporates both data and behaviour.

Object-oriented programming(OOPs) is a methodology that simplify software development and


maintenance by providing some rules.

Basic concepts of OOPs are:

Object

Class

Inheritance

Polymorphism

Abstraction

Encapsulation

Platform Independent

A platform is the hardware or software environment in which a program runs. There are two types of
platforms software-based and hardware-based. Java provides software-based platform. The Java
platform differs from most other platforms in the sense that it's a software-based platform that runs on
top of other hardware-based platforms.It has two components:

Runtime Environment

API(Application Programming Interface)


java is platform independent Java code can be run on multiple platforms e.g.Windows,Linux,Sun
Solaris,Mac/OS etc. Java code is compiled by the compiler and converted into bytecode.This bytecode is
a platform independent code because it can be run on multiple platforms i.e. Write Once and Run
Anywhere(WORA).
Secured

Java is secured because:

No explicit pointer

Programs run inside virtual machine sandbox.


how java is secured how java is secured

Classloader- adds security by separating the package for the classes of the local file system from those
that are imported from network sources.

Bytecode Verifier- checks the code fragments for illegal code that can violate access right to objects.

Security Manager- determines what resources a class can access such as reading and writing to the
local disk.

These security are provided by java language. Some security can also be provided by application
developer through SSL,JAAS,cryptography etc.

Robust

Robust simply means strong. Java uses strong memory management. There are lack of pointers that
avoids security problem. There is automatic garbage collection in java. There is exception handling and
type checking mechanism in java. All these points makes java robust.

Architecture-neutral

There is no implementation dependent features e.g. size of primitive types is set.


A Language or Technology is said to be Architectural neutral which can run on any available

processors in the real world without considering there architecture and vendor (providers)

irrespect to its development and compilation.

Portable

We may carry the java bytecode to any platform.

High-performance

Java is faster than traditional interpretation since byte code is "close" to native code still somewhat
slower than a compiled language (e.g., C++)

Distributed

We can create distributed applications in java. RMI and EJB are used for creating distributed
applications. We may access files by calling the methods from any machine on the internet.
Multi-threaded

A thread is like a separate program, executing concurrently. We can write Java programs that deal with
many tasks at once by defining multiple threads. The main advantage of multi-threading is that it shares
the same memory. Threads are important for multi-media, Web applications etc.

Difference between JDK, JRE and JVM


JVM

JVM (Java Virtual Machine) is an abstract machine. It is a specification that provides runtime
environment in which java bytecode can be executed.

JVMs are available for many hardware and software platforms. JVM, JRE and JDK are platform
dependent because configuration of each OS differs. But, Java is platform independent.

The JVM performs following main tasks:

Loads code

Verifies code

Executes code

Provides runtime environment


JRE

JRE is an acronym for Java Runtime Environment.It is used to provide runtime environment.It is the
implementation of JVM.It physically exists.It contains set of libraries + other files that JVM uses at
runtime.

Implementation of JVMs are also actively released by other companies besides Sun Micro Systems.

DK

JDK is an acronym for Java Development Kit.It physically exists.It contains JRE + development tools.
JVM Architecture

JVM (Java Virtual Machine) is a software. It is a specification that provides runtime environment

in which java bytecode can be executed.


Operation of JVM

JVM mainly performs following operations.

 Allocating sufficient memory space for the class properties.

 Provides runtime environment in which java bytecode can be executed

 Converting byte code instruction into machine level instruction.


JVM is separately available for every Operating System while installing java software so that JVM

is platform dependent.

Note: Java is platform Independent but JVM is platform dependent because every Operating

system have different-different JVM which is install along with JDK Software.

Class loader subsystem:

Class loader subsystem will load the .class file into java stack and later sufficient memory will be

allocated for all the properties of the java program into following five memory locations.

 Heap area

 Method area

 Java stack
 PC register

 Native stack

Heap area:

In which object references will be stored.

Method area

In which static variables non-static and static method will be stored.

Java Stack

In which all the non-static variable of class will be stored and whose address referred by object

reference.

Pc Register

Which holds the address of next executable instruction that means that use the priority for the

method in the execution process?

Native Stack

Native stack holds the instruction of native code (other than java code) native stack depends on

native library. Native interface will access interface between native stack and native library.

Execution Engine

Which contains Interpreter and JIT compiler whenever any java program is executing at the first

time interpreter will comes into picture and it converts one by one byte code instruction into

machine level instruction JIT compiler (just in time compiler) will comes into picture from the

second time onward if the same java program is executing and it gives the machine level

instruction to the process which are available in the buffer memory.

Note: The main aim of JIT compiler is to speed up the execution of java program.
Keywords
Java keywords are also known as reserved words. Keywords are
particular words that act as a key to a code. These are predefined
words by Java so they cannot be used as a variable or object
name or class name.
Identifiers: Identifiers in Java are names that are helpful in uniquely recognizing a class, a
method, a package name, a constant, or a variable. Some words in Java are reserved and cannot
be used as identifiers.
Java Constant

As the name suggests, a constant is an entity in programming that is immutable. In other words,
the value that cannot be changed. In this section, we will learn about Java constant and how to
declare a constant in Java.

What is constant?

Constant is a value that cannot be changed after assigning it. Java does not directly support the
constants. There is an alternative way to define the constants in Java by using the non-access
modifiers static and final.

How to declare constant in Java?

In Java, to declare any variable as constant, we use static and final modifiers. It is also known
as non-access modifiers. According to the Java naming convention the identifier name must be
in capital letters.

Static and Final Modifiers


o The purpose to use the static modifier is to manage the memory.
o It also allows the variable to be available without loading any instance of the class in
which it is defined.
o The final modifier represents that the value of the variable cannot be changed. It also
makes the primitive data type immutable or unchangeable.

The syntax to declare a constant is as follows:


Backward Skip 10sPlay VideoForward Skip 10s
1. static final datatype identifier_name=value;

For example, price is a variable that we want to make constant.


1. static final double PRICE=432.78;

Where static and final are the non-access modifiers. The double is the data type and PRICE is the
identifier name in which the value 432.78 is assigned.

In the above statement, the static modifier causes the variable to be available without an instance
of its defining class being loaded and the final modifier makes the variable fixed.

Here a question arises that why we use both static and final modifiers to declare a constant?

If we declare a variable as static, all the objects of the class (in which constant is defined) will be
able to access the variable and can be changed its value. To overcome this problem, we use
the final modifier with a static modifier.

When the variable defined as final, the multiple instances of the same constant value will be
created for every different object which is not desirable.

When we use static and final modifiers together, the variable remains static and can be
initialized once. Therefore, to declare a variable as constant, we use both static and final
modifiers. It shares a common memory location for all objects of its containing class.

Why we use constants?

The use of constants in programming makes the program easy and understandable which can be
easily understood by others. It also affects the performance because a constant variable is cached
by both JVM and the application.

Points to Remember:
o Write the identifier name in capital letters that we want to declare as constant. For
example, MAX=12.
o If we use the private access-specifier before the constant name, the value of the constant
cannot be changed in that particular class.
o If we use the public access-specifier before the constant name, the value of the constant
can be changed in the program.
public static final double PI= 3.14;

Variable

A variable is the name of a reserved area allocated in memory. In other words, it is a name of the
memory location. It is a combination of "vary + able" which means its value can be changed.

Literals: In Java, literal is a notation that represents a fixed value in the


source code.

Ex:

Types of Literals

1. Integer Literal
2. Character Literal
3. Boolean Literal
4. String Literal
Integer Literals: Integer literals are sequences of digits. There are three types of integer
literals:
o Decimal Integer: These are the set of numbers that consist of digits from 0 to 9. It may
have a positive (+) or negative (-) Note that between numbers commas and non-digit
characters are not permitted.
Ex: 5678, +657, -89, etc.

int decVal = 26;

o Octal Integer: It is a combination of number have digits from 0 to 7 with a leading


Ex: 045, 026,
int octVal = 067;

o Hexa-Decimal: The sequence of digits preceded by 0x or 0X is considered as


hexadecimal integers. It may also include a character from a to f or A to F that represents
numbers from 10 to 15, respectively.
Ex: 0xd, 0xf,
1. int hexVal = 0x1a;
2.
o Binary Integer: Base 2, whose digits consists of the numbers 0 and 1 (you can create
binary literals in Java SE 7 and later). Prefix 0b represents the Binary system. For
Ex: 0b11010.
1. int binVal = 0b11010;

Real Literals

The numbers that contain fractional parts are known as real literals. We can also represent real
literals in exponent form.

Ex: 879.90, 99E-3, etc.

Backslash Literals: Java supports some special backslash character literals known as
backslash literals. They are used in formatted output. For example:

\n: It is used for a new line

\t: It is used for horizontal tab

\b: It is used for blank space

\v: It is used for vertical tab

\a: It is used for a small beep

\r: It is used for carriage return


\': It is used for a single quote

\": It is used for double quotes

Character Literals

A character literal is expressed as a character or an escape sequence, enclosed in a single quote


('') mark. It is always a type of char.

Example, 'a', '%', '\u000d', etc.

String Literals

String literal is a sequence of characters that is enclosed between double quotes ("") marks. It
may be alphabet, numbers, special characters, blank space, etc.

Example, "Jack", "12345", "\n", etc.

Floating Point Literals

The vales that contain decimal are floating literals. In Java, float and double primitive types fall
into floating-point literals. Keep in mind while dealing with floating-point literals.
o Floating-point literals for float type end with F or f. For example, 6f, 8.354F, etc. It is
a 32-bit float literal.
o Floating-point literals for double type end with D or d. It is optional to write D or d. For
example, 6d, 8.354D, etc. It is a 64-bit double literal.
o It can also be represented in the form of the exponent.

Floating: float length = 155.4f;

Decimal: double interest = 99658.445;

Decimal in Exponent form: double val= 1.234e2;

Boolean Literals

Boolean literals are the value that is either true or false. It may also have values 0 and 1. For
example, true, 0, etc.
1. boolean isEven = true;

Null Literals

Null literal is often used in programs as a marker to indicate that reference type object is
unavailable. The value null may be assigned to any variable, except variables of primitive types.
1. String stuName = null;
2. Student age = null;
Class Literals

Class literal formed by taking a type name and appending .class extension. For
example, Scanner.class. It refers to the object (of type Class) that represents the type itself.
1. class classType = Scanner.class;

Data Types in Java

Data types specify the different sizes and values that can be stored in the variable. There are two
types of data types in Java:
1. Primitive data types: The primitive data types include boolean, char, byte, short, int,
long, float and double.
2. Non-primitive data types: The non-primitive data types include Classes, Interfaces,
and Arrays.

Java Primitive Data Types

In Java language, primitive data types are the building blocks of data manipulation. These are the
most basic data types available in Java language.

Java is a statically-typed programming language. It means, all variables must be declared before
its use. That is why we need to declare variable's type and name.

There are 8 types of primitive data types:


Backward Skip 10sPlay VideoForward Skip 10s
o boolean data type
o byte data type
o char data type
o short data type
o int data type
o long data type
o float data type
o double data type
Data Type Default Value Default size

boolean false 1 bit

char '\u0000' 2 byte

byte 0 1 byte

short 0 2 byte

int 0 4 byte

long 0L 8 byte

float 0.0f 4 byte

double 0.0d 8 byte

Boolean Data Type

The Boolean data type is used to store only two possible values: true and false. This data type is
used for simple flags that track true/false conditions.

The Boolean data type specifies one bit of information, but its "size" can't be defined precisely.

Example:
1. Boolean one = false

Byte Data Type

The byte data type is an example of primitive data type. It isan 8-bit signed two's complement
integer. Its value-range lies between -128 to 127 (inclusive). Its minimum value is -128 and
maximum value is 127. Its default value is 0.
The byte data type is used to save memory in large arrays where the memory savings is most
required. It saves space because a byte is 4 times smaller than an integer. It can also be used in
place of "int" data type.

Example:
1. byte a = 10, byte b = -20

Short Data Type

The short data type is a 16-bit signed two's complement integer. Its value-range lies between -
32,768 to 32,767 (inclusive). Its minimum value is -32,768 and maximum value is 32,767. Its
default value is 0.

The short data type can also be used to save memory just like byte data type. A short data type is
2 times smaller than an integer.

Example:
1. short s = 10000, short r = -5000

Int Data Type

The int data type is a 32-bit signed two's complement integer. Its value-range lies between -
2,147,483,648 (-2^31) to 2,147,483,647 (2^31 -1) (inclusive). Its minimum value is -
2,147,483,648and maximum value is 2,147,483,647. Its default value is 0.

The int data type is generally used as a default data type for integral values unless if there is no
problem about memory.

Example:
1. int a = 100000, int b = -200000

Long Data Type

The long data type is a 64-bit two's complement integer. Its value-range lies between -
9,223,372,036,854,775,808(-2^63) to 9,223,372,036,854,775,807(2^63 -1)(inclusive). Its
minimum value is - 9,223,372,036,854,775,808and maximum value is
9,223,372,036,854,775,807. Its default value is 0. The long data type is used when you need a
range of values more than those provided by int.

Example:
1. long a = 100000L, long b = -200000L

Float Data Type

The float data type is a single-precision 32-bit IEEE 754 floating point.Its value range is
unlimited. It is recommended to use a float (instead of double) if you need to save memory in
large arrays of floating point numbers. The float data type should never be used for precise
values, such as currency. Its default value is 0.0F.

Example:
1. float f1 = 234.5f

Double Data Type

The double data type is a double-precision 64-bit IEEE 754 floating point. Its value range is
unlimited. The double data type is generally used for decimal values just like float. The double
data type also should never be used for precise values, such as currency. Its default value is 0.0d.

Example:
1. double d1 = 12.3

Char Data Type

The char data type is a single 16-bit Unicode character. Its value-range lies between '\u0000' (or
0) to '\uffff' (or 65,535 inclusive).The char data type is used to store characters.

Example:
1. char letterA = 'A'

Why char uses 2 byte in java and what is \u0000 ?

It is because java uses Unicode system not ASCII code system. The \u0000 is the lowest range of
Unicode system. To get detail explanation about Unicode visit next page.
Unicode System
Unicode is a universal international standard character encoding that is
capable of representing most of the world's written languages.

Why java uses Unicode System?


Before Unicode, there were many language standards:
o ASCII (American Standard Code for Information Interchange) for
the United States.
o ISO 8859-1 for Western European Language.
o KOI-8 for Russian.
o GB18030 and BIG-5 for chinese, and so on.

Problem
This caused two problems:
1. A particular code value corresponds to different letters in the various
language standards.
2. The encodings for languages with large character sets have variable
length.Some common characters are encoded as single bytes, other
require two or more byte.

Solution
To solve these problems, a new language standard was developed i.e.
Unicode System.
In unicode, character holds 2 byte, so java also uses 2 byte for characters.
lowest value:\u0000
highest value:\uFFFF

Operators in Java

Operator in Java is a symbol that is used to perform operations. For example: +, -, *, / etc.

There are many types of operators in Java which are given below:

instanceof operator: used for type checking. It can be used to test if an object is an
instance of a class, a subclass, or an interface.

Syntx: object instance of class/subclass/interface

Documentation Section
Import Packages

class ClassName
{
Public static void main(String args[])
{
Statement-1;
Statement-2;
:
:
:
Statement-n;
}
}

- As java is a Object Oriented Programming Language, Everything in Java


must be under a class.

As java is a pure Object Oriented programming Languge everything in java must be under a class.

public: indicates that the method can be called by any object.

static: indicates that the method is a class method, which can be called without the requirement to
instantiate an object of the class.

void: indicates that the method doesn’t return any value.

main() method is starting execution block of a java program or any java program start their

execution from main method. If any class contain main() method known as main class.
Args: The formal parameter args is an array of type String, which contains arguments entered at the
command line.

Note: The args parameter must be specified whether or not their is required to enter a command-line
argument and whether or not the code in – Write the method signature for the main
CamelCase in java naming conventions

Java follows camelcase syntax for naming the class, interface, method and variable According to

CamelCase if name is combined with two words, second word will start with uppercase letter

always.

class name: should start with uppercase letter and be a noun

Ex: String, Scanner, DataInputStream, InputerStreamReader, Color, Button, System, Thread etc.

method name: should start with lowercase letter and be a verb

Ex: actionPerformed(),toUpperCase(),toLowerCase(), main(),print(),println() etc.

interface name: should start with uppercase letter and be an adjective

Ex: Runnable, Remote, ActionListener etc.


variable name: should start with lowercase letter

Ex:age,price,firstName, orderNumber etc.

package name: should be in lowercase letter

Ex: java, lang, sql, util etc.

constants name: should be in uppercase letter.

Ex:PI, RED, YELLOW, MAX_PRIORITY etc.

You might also like