SlideShare a Scribd company logo
5
Most read
7
Most read
9
Most read
JAVA
P.Prathibha
Topics for Today’s Session
Differences between C,
C++ & Java
Structure of a Java
Program
Differences between C, C++ and Java
Feature C C++ Java
Programming
Paradigm
Procedural
language
Object-Oriented
Programming (OOP)
Pure Object
Oriented Oriented
Origin
Based on assembly
language
Based on C language Based on C and C++
Developer
Dennis Ritchie in
1972
Bjarne Stroustrup in
1979
James Gosling in
1991
Translator Compiler only Compiler only
Interpreted language
(Compiler + interpreter)
Platform
Dependency
Platform Dependent Platform Dependent
Platform
Independent
Code execution Direct Direct Executed by JVM
Approach Top-down Bottom-up Bottom-up
File generation .exe files .exe files .class files
Pre-processor
directives
Support header files
(#include, #define)
Supported (#header,
#define)
Use Packages
(import)
keywords 32 keywords 63 keywords 50 keywords
Contd..
Feature C C++ Java
Datatypes (union,
structure)
Supported Supported Not supported
Inheritance No inheritance Supported
Supported except
Multiple inheritance
Overloading No overloading
Support Function overloading
(Polymorphism)
Operator overloading is
not supported
Pointers Supported Supported Not supported
Allocation Use malloc, calloc Use new, delete Garbage collector
Exception Handling Not supported Supported Supported
Templates Not supported Supported Not supported
Destructors
No constructor
neither destructor
Supported Not supported
Multithreading/
Interfaces
Not supported Not supported Supported
Database
connectivity
Not supported Not supported Supported
Storage Classes
Supported ( auto,
extern )
Supported ( auto, extern ) Not supported
Structure of a Java Program
Documentation Section:
 It includes the comments that improve the readability of the
program.
 It consists comments in Java that describe the purpose of the
program, author name, date and time of program creation.
 This section is optional and comments may appear anywhere
in the program.
Java programming language supports three types of
comments..
 Single line Comment (or end-of line comment)
 It starts with a double slash symbol (//) and terminates at the end
of the current line.
Ex: // sum of two numbers
 Multi-line Comment
/* a multi-line comment is declared like this
and can have multiple lines as a comment */
 Documentation Comment
 /** a documentation comment starts with a delimiter and ends
with */
Package Statement
 A package is a collection of classes, interfaces and sub-
packages.
 A sub package contains collection of classes, interfaces and
sub-sub packages etc.
 There is a provision in Java that allows you to declare your
classes in a collection called package.
 There can be only one package statement in a Java program.
 It must appear as the first statement in the source code file
before any class or interface declaration.
 This statement is optional,
Syntax: package package_name;
Example: package student;
 This statement declares that all the classes and interfaces
defined in this source file are a part of the student package.
java.lang.*;
package is imported by default and this package is
known as default package.
Import Statement
 Many predefined classes are stored in packages in Java, an
import statement is used to refer to the classes stored in other
packages.
 An import statement is always written after the package
statement but it has to be before any class declaration.
 You can import a specific class or all the classes of the
package.
 Many classes can be imported in a single program and hence
multiple import statements can be written.
import java.util.Date; //imports the date class
import java.applet.*; //imports all the classes from the java applet package
Interface Section
 This section is used to specify an interface in Java.
 It is an optional section which is mainly used to implement
multiple inheritance in Java
 An interface is similar to a class but contains only constants
and method declarations.
 An Interfaces cannot be instantiated.
 They can only be implemented by classes or extended by other
interfaces.
Interface shape{
void draw(int length, int bredth);
void show();
}
Class Definition
 Java program may contain multiple class definition.
 Classes are primary feature of Java program.
 The classes are used to map real world problems.
 classes defines the information about the user-defined classes
in a program.
 A class is a collection of variables and methods that operate on
the fields.
 Every program in Java will have at least one class with the main
method.
class Addition
{
void add(String args[])
{
int a=2, b=3, c;
c=a+b;
System.out.println(c);
}
}
Main Method Class
 Execution of a Java application starts from the main method.
 In other words, its an entry point for the class or program that
starts in Java Run-time.
 The main () method which is from where the execution of program
actually starts and follow the statements in the order specified.
 The main method can create objects, evaluate expressions, and invoke
other methods and much more.
 On reaching the end of main, the program terminates and control
passes back to the operating system.
 The class section is mandatory.
// Program to display message on the screen
class HelloJava {
public static void main(String args[])
{
System.out.println("Hello Harsha");
} }
Summary
 In this lesson you learnt about
 Java
 Differences between C , C++ and Java
 Structure of Java Program
Structure of java program  diff c- cpp and java

More Related Content

PPTX
PROGRAMMING IN JAVA unit 1.pptx
SeethaDinesh
 
PPTX
Friend function
zindadili
 
PPTX
Inheritance in java
yash jain
 
PPTX
Classes objects in java
Madishetty Prathibha
 
PPTX
oops concept in java | object oriented programming in java
CPD INDIA
 
PDF
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
PPTX
Data types in c++
Venkata.Manish Reddy
 
PPTX
Method overloading
Lovely Professional University
 
PROGRAMMING IN JAVA unit 1.pptx
SeethaDinesh
 
Friend function
zindadili
 
Inheritance in java
yash jain
 
Classes objects in java
Madishetty Prathibha
 
oops concept in java | object oriented programming in java
CPD INDIA
 
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
Data types in c++
Venkata.Manish Reddy
 
Method overloading
Lovely Professional University
 

What's hot (20)

PPT
Inheritance in java
Lovely Professional University
 
PPT
Final keyword in java
Lovely Professional University
 
PPTX
classes and objects in C++
HalaiHansaika
 
PPTX
Inheritance in java
Tech_MX
 
PPTX
class and objects
Payel Guria
 
PPTX
Java Tokens
Madishetty Prathibha
 
PPT
Java interfaces
Raja Sekhar
 
PPTX
inheritance c++
Muraleedhar Sundararajan
 
PPTX
Virtual base class
Tech_MX
 
PPSX
Files in c++
Selvin Josy Bai Somu
 
PPTX
Exception Handling in Java
lalithambiga kamaraj
 
PPTX
Inheritance in c++
Vishal Patil
 
PPSX
Inheritance
Selvin Josy Bai Somu
 
PPTX
Exception handling in java
ravinderkaur165
 
PPTX
Data Type Conversion in C++
Danial Mirza
 
PPTX
Polymorphism presentation in java
Ahsan Raja
 
PPTX
Inheritance in c++
Vineeta Garg
 
PPTX
Constructor in java
Pavith Gunasekara
 
PPTX
JAVA ENVIRONMENT
josemachoco
 
PPTX
Methods in java
chauhankapil
 
Inheritance in java
Lovely Professional University
 
Final keyword in java
Lovely Professional University
 
classes and objects in C++
HalaiHansaika
 
Inheritance in java
Tech_MX
 
class and objects
Payel Guria
 
Java interfaces
Raja Sekhar
 
inheritance c++
Muraleedhar Sundararajan
 
Virtual base class
Tech_MX
 
Files in c++
Selvin Josy Bai Somu
 
Exception Handling in Java
lalithambiga kamaraj
 
Inheritance in c++
Vishal Patil
 
Exception handling in java
ravinderkaur165
 
Data Type Conversion in C++
Danial Mirza
 
Polymorphism presentation in java
Ahsan Raja
 
Inheritance in c++
Vineeta Garg
 
Constructor in java
Pavith Gunasekara
 
JAVA ENVIRONMENT
josemachoco
 
Methods in java
chauhankapil
 
Ad

Similar to Structure of java program diff c- cpp and java (20)

PPT
Classes and Objects
vmadan89
 
PPTX
java interface and packages
VINOTH R
 
PPTX
Java subject for the degree BCA students
NithinKuditinamaggi
 
PPTX
Chapter 2.1
sotlsoc
 
DOCX
Unit of competency
loidasacueza
 
PPTX
Java
Sneha Mudraje
 
PPT
Introduction
richsoden
 
PPTX
Basics of java 2
Raghu nath
 
PDF
Java programming basics
Hamid Ghorbani
 
PPTX
The smartpath information systems java
The Smartpath Information Systems,Bhilai,Durg,Chhattisgarh.
 
PPT
Java Tutorial 1
Tushar Desarda
 
PPT
Jacarashed-1746968053-300050282-Java.ppt
DilipDas70
 
PPTX
Objects and classes in OO Programming concepts
researchveltech
 
PDF
Understanding And Using Reflection
Ganesh Samarthyam
 
PPTX
10-Lecture10_Leeeeeeeeeeeeeeeecture.pptx
ssuser7fe189
 
PPT
web program-Inheritance,pack&except in Java.ppt
mcjaya2024
 
PPT
Basics of java 1
Vijay Kankane
 
PPT
Fundamentals of oop lecture 2
miiro30
 
PDF
OOPS JAVA.pdf
DeepanshuMidha5140
 
PPT
Csci360 20 (1)
manish katara
 
Classes and Objects
vmadan89
 
java interface and packages
VINOTH R
 
Java subject for the degree BCA students
NithinKuditinamaggi
 
Chapter 2.1
sotlsoc
 
Unit of competency
loidasacueza
 
Introduction
richsoden
 
Basics of java 2
Raghu nath
 
Java programming basics
Hamid Ghorbani
 
The smartpath information systems java
The Smartpath Information Systems,Bhilai,Durg,Chhattisgarh.
 
Java Tutorial 1
Tushar Desarda
 
Jacarashed-1746968053-300050282-Java.ppt
DilipDas70
 
Objects and classes in OO Programming concepts
researchveltech
 
Understanding And Using Reflection
Ganesh Samarthyam
 
10-Lecture10_Leeeeeeeeeeeeeeeecture.pptx
ssuser7fe189
 
web program-Inheritance,pack&except in Java.ppt
mcjaya2024
 
Basics of java 1
Vijay Kankane
 
Fundamentals of oop lecture 2
miiro30
 
OOPS JAVA.pdf
DeepanshuMidha5140
 
Csci360 20 (1)
manish katara
 
Ad

More from Madishetty Prathibha (11)

PPTX
Object Oriented programming - Introduction
Madishetty Prathibha
 
PPTX
Access modifiers in java
Madishetty Prathibha
 
PPTX
Constructor in java
Madishetty Prathibha
 
PPTX
Control statements in java
Madishetty Prathibha
 
PPTX
Operators in java
Madishetty Prathibha
 
PPTX
Types of datastructures
Madishetty Prathibha
 
PPTX
Introduction to algorithms
Madishetty Prathibha
 
PDF
Java data types, variables and jvm
Madishetty Prathibha
 
PPTX
Introduction to data structures (ss)
Madishetty Prathibha
 
PPT
Java features
Madishetty Prathibha
 
PPSX
Introduction of java
Madishetty Prathibha
 
Object Oriented programming - Introduction
Madishetty Prathibha
 
Access modifiers in java
Madishetty Prathibha
 
Constructor in java
Madishetty Prathibha
 
Control statements in java
Madishetty Prathibha
 
Operators in java
Madishetty Prathibha
 
Types of datastructures
Madishetty Prathibha
 
Introduction to algorithms
Madishetty Prathibha
 
Java data types, variables and jvm
Madishetty Prathibha
 
Introduction to data structures (ss)
Madishetty Prathibha
 
Java features
Madishetty Prathibha
 
Introduction of java
Madishetty Prathibha
 

Recently uploaded (20)

PDF
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
PDF
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
Sourav Kr Podder
 
PPTX
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
PPTX
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
PPTX
Presentation on Janskhiya sthirata kosh.
Ms Usha Vadhel
 
PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PDF
High Ground Student Revision Booklet Preview
jpinnuck
 
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
Sourav Kr Podder
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PDF
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
PPTX
Congenital Hypothyroidism pptx
AneetaSharma15
 
PPTX
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
PPTX
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
PPTX
Introduction and Scope of Bichemistry.pptx
shantiyogi
 
PPTX
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PPTX
How to Manage Global Discount in Odoo 18 POS
Celine George
 
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
Open Quiz Monsoon Mind Game Final Set.pptx
Sourav Kr Podder
 
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
Presentation on Janskhiya sthirata kosh.
Ms Usha Vadhel
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
High Ground Student Revision Booklet Preview
jpinnuck
 
Open Quiz Monsoon Mind Game Prelims.pptx
Sourav Kr Podder
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
Congenital Hypothyroidism pptx
AneetaSharma15
 
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
Introduction and Scope of Bichemistry.pptx
shantiyogi
 
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
How to Manage Global Discount in Odoo 18 POS
Celine George
 

Structure of java program diff c- cpp and java

  • 2. Topics for Today’s Session Differences between C, C++ & Java Structure of a Java Program
  • 3. Differences between C, C++ and Java Feature C C++ Java Programming Paradigm Procedural language Object-Oriented Programming (OOP) Pure Object Oriented Oriented Origin Based on assembly language Based on C language Based on C and C++ Developer Dennis Ritchie in 1972 Bjarne Stroustrup in 1979 James Gosling in 1991 Translator Compiler only Compiler only Interpreted language (Compiler + interpreter) Platform Dependency Platform Dependent Platform Dependent Platform Independent Code execution Direct Direct Executed by JVM Approach Top-down Bottom-up Bottom-up File generation .exe files .exe files .class files Pre-processor directives Support header files (#include, #define) Supported (#header, #define) Use Packages (import) keywords 32 keywords 63 keywords 50 keywords
  • 4. Contd.. Feature C C++ Java Datatypes (union, structure) Supported Supported Not supported Inheritance No inheritance Supported Supported except Multiple inheritance Overloading No overloading Support Function overloading (Polymorphism) Operator overloading is not supported Pointers Supported Supported Not supported Allocation Use malloc, calloc Use new, delete Garbage collector Exception Handling Not supported Supported Supported Templates Not supported Supported Not supported Destructors No constructor neither destructor Supported Not supported Multithreading/ Interfaces Not supported Not supported Supported Database connectivity Not supported Not supported Supported Storage Classes Supported ( auto, extern ) Supported ( auto, extern ) Not supported
  • 5. Structure of a Java Program
  • 6. Documentation Section:  It includes the comments that improve the readability of the program.  It consists comments in Java that describe the purpose of the program, author name, date and time of program creation.  This section is optional and comments may appear anywhere in the program. Java programming language supports three types of comments..  Single line Comment (or end-of line comment)  It starts with a double slash symbol (//) and terminates at the end of the current line. Ex: // sum of two numbers  Multi-line Comment /* a multi-line comment is declared like this and can have multiple lines as a comment */  Documentation Comment  /** a documentation comment starts with a delimiter and ends with */
  • 7. Package Statement  A package is a collection of classes, interfaces and sub- packages.  A sub package contains collection of classes, interfaces and sub-sub packages etc.  There is a provision in Java that allows you to declare your classes in a collection called package.  There can be only one package statement in a Java program.  It must appear as the first statement in the source code file before any class or interface declaration.  This statement is optional, Syntax: package package_name; Example: package student;  This statement declares that all the classes and interfaces defined in this source file are a part of the student package. java.lang.*; package is imported by default and this package is known as default package.
  • 8. Import Statement  Many predefined classes are stored in packages in Java, an import statement is used to refer to the classes stored in other packages.  An import statement is always written after the package statement but it has to be before any class declaration.  You can import a specific class or all the classes of the package.  Many classes can be imported in a single program and hence multiple import statements can be written. import java.util.Date; //imports the date class import java.applet.*; //imports all the classes from the java applet package
  • 9. Interface Section  This section is used to specify an interface in Java.  It is an optional section which is mainly used to implement multiple inheritance in Java  An interface is similar to a class but contains only constants and method declarations.  An Interfaces cannot be instantiated.  They can only be implemented by classes or extended by other interfaces. Interface shape{ void draw(int length, int bredth); void show(); }
  • 10. Class Definition  Java program may contain multiple class definition.  Classes are primary feature of Java program.  The classes are used to map real world problems.  classes defines the information about the user-defined classes in a program.  A class is a collection of variables and methods that operate on the fields.  Every program in Java will have at least one class with the main method. class Addition { void add(String args[]) { int a=2, b=3, c; c=a+b; System.out.println(c); } }
  • 11. Main Method Class  Execution of a Java application starts from the main method.  In other words, its an entry point for the class or program that starts in Java Run-time.  The main () method which is from where the execution of program actually starts and follow the statements in the order specified.  The main method can create objects, evaluate expressions, and invoke other methods and much more.  On reaching the end of main, the program terminates and control passes back to the operating system.  The class section is mandatory. // Program to display message on the screen class HelloJava { public static void main(String args[]) { System.out.println("Hello Harsha"); } }
  • 12. Summary  In this lesson you learnt about  Java  Differences between C , C++ and Java  Structure of Java Program