0% found this document useful (0 votes)
20 views

Java_2

The document outlines the features and structure of Java programming, highlighting its simplicity, object-oriented nature, portability, and security. It details the standard format for Java programs, including the importance of the main() method and class definitions. Additionally, it provides a step-by-step guide to creating and running a 'Hello World' program using the Eclipse IDE.

Uploaded by

laksh.sharma1031
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Java_2

The document outlines the features and structure of Java programming, highlighting its simplicity, object-oriented nature, portability, and security. It details the standard format for Java programs, including the importance of the main() method and class definitions. Additionally, it provides a step-by-step guide to creating and running a 'Hello World' program using the Eclipse IDE.

Uploaded by

laksh.sharma1031
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

JAVA STRUCTURE

By : Kapil Manchandani
TABLE OF CONTENT
 Features of Java.
 Structure of Java Programming

 JVM Architecture
 Parameters used in First Java Program
FEATURES OF JAVA
 Simple
 Object-Oriented

 Portable

 Platform independent

 Secured

 Robust

 Interpreted

 High Performance

 Multithreaded

 Distributed
 Simple : Java is very easy to learn, Easy to Understand and its syntax is
very simple.
 Java syntax is based on C++ (so easier for programmers to learn it after
C++).
 Java has removed many complicated features, for example, explicit
pointers, operator overloading (that was used in C++ language), etc.
 There is no need to remove unreferenced objects because there is an
Automatic Garbage Collection in Java.
 Object Oriented : An object can be defined as an instance of a class, and
there can be multiple instances of a class in a program. An Object is one
of the Java OOPs concepts which contains both the data and the
function, which operates on the data. For example – chair, bike, marker,
pen, table, car, etc.
Portable : Java is portable because it facilitates you to carry the Java
bytecode to any platform. It doesn't require any implementation.
Portability refers to the ability to run a program on different
machines. Running a given program on different machines can require
different amounts of work (for example, no work whatsoever,
recompiling, or making small changes to the source code).
 Platform independent: In Java, programs are compiled into byte code
and that byte code is platform-independent. The byte code is executed
by the Java Virtual Machine and the Java Virtual Machine is platform
dependent. Java is platform-independent. Any machine to execute the
byte code needs the Java Virtual Machine.
 Security : JVM is an interpreter which is installed in each client machine
that is updated with latest security updates by internet . When this byte
codes are executed , the JVM can take care of the security. So, java is
said to be more secure than other programming languages.
 Robust : The English mining of Robust is strong. Java is robust because:
 It uses strong memory management.
 There is a lack of pointers that avoids security problems.
 Java provides automatic garbage collection which runs on the Java
Virtual Machine to get rid of objects which are not being used by a Java
application anymore.
 There are exception handling and the type checking mechanism in Java.
All these points make Java robust.
 Interpreted : Java can be considered both a compiled and an
interpreted language because its source code is first compiled into a
binary byte-code. This byte-code runs on the Java Virtual Machine (JVM),
which is usually a software-based interpreter.
 High Performance : With the use of Just-In-Time compilers, Java enables
high performance.
 Multi Threading : Java multithreading feature makes it possible to write
program that can do many tasks simultaneously. Benefit of multithreading
is that it utilizes same memory and other resources to execute multiple
threads at the same time, like While typing, grammatical errors are
checked along.
 Distributed : It is created for the distributed environment of the Internet.
 Facilitates distributed computing as its network-centric.
PLATFORM INDEPENDENT
 Structure of a java program is the standard format released by Language
developer to the Industry programmer.
 Sun Micro System has prescribed the following structure for the java
programmers for developing java application.
 A package is a collection of classes, interfaces and sub-packages. A sub
package contains collection of classes, interfaces and sub-sub packages
etc. java.lang.*; package is imported by default and this package is known
as default package.
 Class is keyword used for developing user defined data type and every
java program must start with a concept of class.
 "ClassName" represent a java valid variable name treated as a name of
the class each and every class name in java is treated as user-defined data
type.
 Data member represents either instance or static they will be selected
based on the name of the class.
 User-defined methods represents either instance or static they are meant
for performing the operations either once or each and every time.
 Each and every java program starts execution from the main() method.
And hence main() method is known as program driver.
 Since main() method of java is not returning any value and hence its
return type must be void.
 Since main() method of java executes only once throughout the java
program execution and hence its nature must be static.
 Since main() method must be accessed by every java programmer and
hence whose access specifier must be public.
 Each and every main() method of java must take array of objects of
String.
 Block of statements represents set of executable statements which are in
term calling user-defined methods are containing business-logic.
 The file naming conversion in the java programming is that which-ever
class is containing main() method, that class name must be given as a file
name with an extension .java.\
WRITE FIRST PROGRAM IN JAVA
Creating a Hello World Program in Java is not a single line program. It
consists of various other lines of code. Since Java is a Object-oriented
language so it require to write a code inside a class. Let us look at a
simple java program.
class Hello
{
public static void main(String[] args)
{
System.out.println ("Hello World program");
}
}
LETS UNDERSTAND WHAT ABOVE PROGRAM
CONSISTS OF AND ITS KEYPOINTS.
class : class keyword is used to declare classes in Java
public : It is an access specifier. Public means this function is visible to all.
static : static is again a keyword used to make a function static. To execute
a static function you do not have to create an Object of the class.
The main() method here is called by JVM, without creating any object
for class.
void : It is the return type, meaning this function will not return anything.
main : main() method is the most important method in a Java program.
This is the method which is executed, hence all the logic must be inside
the main() method. If a java class is not having a main() method, it
causes compilation error.
String[] args : This represents an array whose type is String and name is
args. We will discuss more about array in Java Array section.
System.out.println : This is used to print anything on the console
like printf in C language.
HELLO WORLD PROGRAM USING ECLIPSE
 Here we will see how to create and run hello world program using eclipse
IDE. It require following steps that consists of creating project, class file,
writing code, running code etc.
 Run Eclipse and Create Project
 Open eclipse startup and then create new project. To create project click
on File menu and select Java project option. It will open a window that
ask for project name. Provide the project name and click on the finish
button.
 After creating project, we can see our new created project in the left side
bar that looks like below.
Create Java Class
Now create Java class file by right
click on the project and select
class file option. It will open a window to
ask for class name, provide the class
name and click on finish button.
Now run the program by
selecting Run menu from the menu
bar or use Ctrl+F11 button
combination. After running, it will
print Hello World to the console which
is just bottom to the program window.
THANK YOU ?

You might also like