6
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
This keyword in java
PPTX
Inheritance
PPTX
Super keyword in java
PPTX
Interfaces in java
PPT
Abstract class in java
PPT
Swing and AWT in java
PPTX
Static Data Members and Member Functions
PPTX
Static Members-Java.pptx
This keyword in java
Inheritance
Super keyword in java
Interfaces in java
Abstract class in java
Swing and AWT in java
Static Data Members and Member Functions
Static Members-Java.pptx

What's hot (20)

PPT
Java-java virtual machine
PPTX
Exception handling in java
PPTX
Inheritance in java
ODP
OOP java
PPSX
Files in c++
PPTX
Polymorphism in java
PPTX
SUBQUERIES.pptx
PPTX
Interfaces in java
PPT
Java static keyword
PPTX
Constructor and Destructor
PPTX
Exception Handling in C#
PPT
Object Oriented Programming Concepts
PPTX
Constructor overloading & method overloading
PPTX
Method overloading
PPTX
Inheritance in c++
PPTX
Operators in java
PPTX
Type casting
PDF
Life cycle-of-a-thread
PDF
Basic Java Programming
Java-java virtual machine
Exception handling in java
Inheritance in java
OOP java
Files in c++
Polymorphism in java
SUBQUERIES.pptx
Interfaces in java
Java static keyword
Constructor and Destructor
Exception Handling in C#
Object Oriented Programming Concepts
Constructor overloading & method overloading
Method overloading
Inheritance in c++
Operators in java
Type casting
Life cycle-of-a-thread
Basic Java Programming
Ad

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

PPT
Classes and Objects
PPTX
java interface and packages
PPTX
Java subject for the degree BCA students
PPTX
Chapter 2.1
DOCX
Unit of competency
PPTX
PPT
Introduction
PPTX
Basics of java 2
PDF
Java programming basics
PPTX
The smartpath information systems java
PPT
Java Tutorial 1
PPT
Jacarashed-1746968053-300050282-Java.ppt
PPTX
Objects and classes in OO Programming concepts
PDF
Understanding And Using Reflection
PPTX
10-Lecture10_Leeeeeeeeeeeeeeeecture.pptx
PPT
web program-Inheritance,pack&except in Java.ppt
PPT
Basics of java 1
PPT
Fundamentals of oop lecture 2
PDF
OOPS JAVA.pdf
PPT
Csci360 20 (1)
Classes and Objects
java interface and packages
Java subject for the degree BCA students
Chapter 2.1
Unit of competency
Introduction
Basics of java 2
Java programming basics
The smartpath information systems java
Java Tutorial 1
Jacarashed-1746968053-300050282-Java.ppt
Objects and classes in OO Programming concepts
Understanding And Using Reflection
10-Lecture10_Leeeeeeeeeeeeeeeecture.pptx
web program-Inheritance,pack&except in Java.ppt
Basics of java 1
Fundamentals of oop lecture 2
OOPS JAVA.pdf
Csci360 20 (1)
Ad

More from Madishetty Prathibha (14)

PPTX
Object Oriented programming - Introduction
PPTX
Access modifiers in java
PPTX
Constructor in java
PPTX
Control statements in java
PPTX
Classes objects in java
PPTX
Operators in java
PPTX
Types of datastructures
PPTX
Introduction to algorithms
PDF
Java data types, variables and jvm
PPTX
Introduction to data structures (ss)
PPTX
PDF
Oops concepts || Object Oriented Programming Concepts in Java
PPT
Java features
PPSX
Introduction of java
Object Oriented programming - Introduction
Access modifiers in java
Constructor in java
Control statements in java
Classes objects in java
Operators in java
Types of datastructures
Introduction to algorithms
Java data types, variables and jvm
Introduction to data structures (ss)
Oops concepts || Object Oriented Programming Concepts in Java
Java features
Introduction of java

Recently uploaded (20)

PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
PDF
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
PDF
IGGE1 Understanding the Self1234567891011
PDF
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
PPTX
TNA_Presentation-1-Final(SAVE)) (1).pptx
PDF
advance database management system book.pdf
PDF
HVAC Specification 2024 according to central public works department
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PDF
My India Quiz Book_20210205121199924.pdf
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PDF
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PPTX
Introduction to pro and eukaryotes and differences.pptx
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
PPTX
Virtual and Augmented Reality in Current Scenario
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
20th Century Theater, Methods, History.pptx
B.Sc. DS Unit 2 Software Engineering.pptx
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
IGGE1 Understanding the Self1234567891011
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
TNA_Presentation-1-Final(SAVE)) (1).pptx
advance database management system book.pdf
HVAC Specification 2024 according to central public works department
AI-driven educational solutions for real-life interventions in the Philippine...
My India Quiz Book_20210205121199924.pdf
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
Share_Module_2_Power_conflict_and_negotiation.pptx
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
Introduction to pro and eukaryotes and differences.pptx
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
Virtual and Augmented Reality in Current Scenario
202450812 BayCHI UCSC-SV 20250812 v17.pptx
20th Century Theater, Methods, History.pptx

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