0% found this document useful (0 votes)
19 views15 pages

Introduction

Java is a high-level, platform-independent programming language that follows object-oriented principles. It operates on a 'Write once, Run anywhere' principle, allowing Java class files to run on any operating system. The document also outlines Java's syntax rules, naming conventions for identifiers, and the structure of Java source files, along with an introduction to UML diagrams for visualizing Java components.

Uploaded by

libog84729
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views15 pages

Introduction

Java is a high-level, platform-independent programming language that follows object-oriented principles. It operates on a 'Write once, Run anywhere' principle, allowing Java class files to run on any operating system. The document also outlines Java's syntax rules, naming conventions for identifiers, and the structure of Java source files, along with an introduction to UML diagrams for visualizing Java components.

Uploaded by

libog84729
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

• Java is basically a HIGH LEVEL, platform

independent, programming language, which


works on principles of OBJECT ORIENTATION.

• High Level…. ?
• Platform Independent…?
• Object Orientation…?
Computer language hierarchy :
(Higher is the language ‘lower’ is the complexity
, at highest level the language will be simplest)
• High-Level language (java, c, c++…)

• Assembly Language

• Machine Language

• Hardware
Example
• In high level language if we want to store 23 in a
location in ram, then we just have to give the location a
name like “location” and then
Location = 23; (simplest) 

• In assembly language same thing can be done with


following command
Move #23, d4 (where d4 is the location of register)

• In machine language same thing can be done


with………no one knows!!!!
00001111 11010101 10101 
Platform independent
• By platform independence of java we means
the class file of java can run on any operating
system (windows, Linux, Mac etc).
• It works on “Write once Run anywhere
principle”.
How java code works!!
• Basically working of java is divided into three
parts:
1. Java compiler
2. Java interpreter
3. JVM
• If your code is according to “strict” syntax rules of
java, then compiler allows to pass the code, but
after changing it into “Byte code” which is not
understandable by human beings, only machine
can understand it.
• After converting of your code into byte Code, the
interpreter executes the byte code line by line and
gives our instructions to the JVM.
• JVM finally accepts this instructions and pass this
instructions to our “environment” in a language
which is understandable by the environment.
Note: basically Java inteperator is the part of JVM)
Java files
Java source files Java class files
• Source files are simple text • Java class files are just
files in which we write our “compiled version” of
source codes and saved source files which is
them with extension of generated by compiler and
“.java” having “.class” extension.
Camel Casing
• Camel casing is programmer’s way of
combining more than two words into a single
word e.g.
batmanBegins
TheDarkKnight
TheDarkKnightRises
So next time when you see these long strings
then just break them at capital letters!!!
• Identifiers are nothing but the legal name of
java components.
The java components can be
• variables,
• classes,
• methods,
• Interfaces and constants.
Rules for naming identifiers
1. Java “reserved” keyword cannot be used as an
identifier e.g. public, static, void, main etc.
2. First character of an Identifier should be a
alphabetic character (a to z), dollar symbol ($) or
Connection character (_)
(any number or special character is not permitted)
3. After first character, other characters can be
combination of $,_,(a to z),(0 to 9)
4. Special characters are not permitted at any case.
• Which of the following identifiers are expected to give
compilation error and why :
I. ____20
II. 0to9
III. AtoZ
IV. My20$note
V. Tutor_way2automation.com
VI. ___________________
VII. blackBrownFoxJumpOverTheLazyDog
Java Components Naming Standard
• Rules for classes :
First character should be capital then camel casing. The name should
represent a noun e.g. Dog, Account, Way2Automation etc.
• Rules for interfaces :
First character should be capital then camel casing. The name should
represent “adjectives”. E.g. Runnable, ActionListener, Serializable.
• Rules for methods :
First character should be small, then camel casing and the name
should represent verb-Noun pair e.g. getResult, doCalculation etc.
• Rules for variables :
First character should be small then camel casing, and the name
should be small meaning words e.g. buttonWidth,
accountBalance, myList etc.
• Rules for constants :
All characters should be in upper case and to connect them
connection character (_) should be used. E.g. EXIT_ON_CLOSE,
MIN_HEIGHT, PI
Java Source file declaration rules
• The first statement should be a “package”
statement and there must be only one package
statement.
• The second statement (if there is a package
statement) should always be “import” statement
and there can any number of import statements
per source file.
• There can be only one “public class” per source
file and the name of the source file should be
same as of “public class”.
• There can be multiple non-public classes.
• For the files with non-public class the name of
source file can be anything.
UML diagram
• UML (or unified modeling language) diagram is
basically a mechanism to visualize our java
components and relationship between them.
• UML is a modeling language which is used to
create the model or blue print of a software
application.
• It is not a programming language, it is a pictorial
language. Through this language we can visualize
how our classes or other java components are
connected to each other.
UML diagram of a class
First java program
• Class FirstProgram
• {
• Public static void main(String[] args)
• {
• System.out.println(“hello world”);
• }
• }

You might also like