SlideShare a Scribd company logo
5
Most read
6
Most read
7
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

What's hot (20)

PPTX
java interface and packages
VINOTH R
 
PPTX
This keyword in java
Hitesh Kumar
 
PPTX
class and objects
Payel Guria
 
PPTX
I/O Streams
Ravi Chythanya
 
PPTX
Operator overloading
Burhan Ahmed
 
PPTX
Access Modifier.pptx
Margaret Mary
 
PPTX
Super Keyword in Java.pptx
KrutikaWankhade1
 
PPT
Java Presentation
pm2214
 
PDF
Arrays in Java
Naz Abdalla
 
PPTX
Classes, objects in JAVA
Abhilash Nair
 
PPTX
Constructor in java
Pavith Gunasekara
 
PPTX
classes and objects in C++
HalaiHansaika
 
PPTX
Constructor and Types of Constructors
Dhrumil Panchal
 
PPT
Final keyword in java
Lovely Professional University
 
PPTX
07. Virtual Functions
Haresh Jaiswal
 
PPTX
Strings in c++
Neeru Mittal
 
PDF
Operator overloading C++
Lahiru Dilshan
 
PPTX
Constructor overloading & method overloading
garishma bhatia
 
PDF
Constructor and Destructor
Kamal Acharya
 
java interface and packages
VINOTH R
 
This keyword in java
Hitesh Kumar
 
class and objects
Payel Guria
 
I/O Streams
Ravi Chythanya
 
Operator overloading
Burhan Ahmed
 
Access Modifier.pptx
Margaret Mary
 
Super Keyword in Java.pptx
KrutikaWankhade1
 
Java Presentation
pm2214
 
Arrays in Java
Naz Abdalla
 
Classes, objects in JAVA
Abhilash Nair
 
Constructor in java
Pavith Gunasekara
 
classes and objects in C++
HalaiHansaika
 
Constructor and Types of Constructors
Dhrumil Panchal
 
Final keyword in java
Lovely Professional University
 
07. Virtual Functions
Haresh Jaiswal
 
Strings in c++
Neeru Mittal
 
Operator overloading C++
Lahiru Dilshan
 
Constructor overloading & method overloading
garishma bhatia
 
Constructor and Destructor
Kamal Acharya
 

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

PPT
Classes and Objects
vmadan89
 
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
 
PPT
Csci360 20
neetukalra
 
Classes and Objects
vmadan89
 
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
 
Csci360 20
neetukalra
 
Ad

More from Madishetty Prathibha (12)

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
 
PDF
Oops concepts || Object Oriented Programming Concepts in Java
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
 
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
Java features
Madishetty Prathibha
 
Introduction of java
Madishetty Prathibha
 
Ad

Recently uploaded (20)

PPTX
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PDF
IMPORTANT GUIDELINES FOR M.Sc.ZOOLOGY DISSERTATION
raviralanaresh2
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PDF
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
PPTX
ENGlish 8 lesson presentation PowerPoint.pptx
marawehsvinetshe
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PPTX
SD_GMRC5_Session 6AB_Dulog Pedagohikal at Pagtataya (1).pptx
NickeyArguelles
 
PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
PDF
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PPTX
Light Reflection and Refraction- Activities - Class X Science
SONU ACADEMY
 
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
IMPORTANT GUIDELINES FOR M.Sc.ZOOLOGY DISSERTATION
raviralanaresh2
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
ENGlish 8 lesson presentation PowerPoint.pptx
marawehsvinetshe
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
SD_GMRC5_Session 6AB_Dulog Pedagohikal at Pagtataya (1).pptx
NickeyArguelles
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
Controller Request and Response in Odoo18
Celine George
 
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Light Reflection and Refraction- Activities - Class X Science
SONU ACADEMY
 

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