0% found this document useful (0 votes)
38 views18 pages

Lecture 1 Introduction

Uploaded by

Khunsha farooq
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
38 views18 pages

Lecture 1 Introduction

Uploaded by

Khunsha farooq
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 18

JAVA Programming (CST359)

Lecture 1: Introduction to JAVA Programming

Department of Computer Science and Engineering


National Institute of Technology, Srinagar, Jammu and Kashmir
March 02, 2023
Syllabus
Recommended Books
Popularity of Programming Languages

Source: https://www.zdnet.com/article/top-programming-languages-most-popular-and-fastest-growing-choices-for-developers/
Introduction to JAVA Programming
• Java is a class based, high-level, object-oriented programming language
developed by Sun Microsystems of the USA in 1991.
• It was originally called Oak by James Goslin. He was one of the inventors of
Java.
• JAVA was acquired by Oracle in year 2009.
• The aim of developing java language was to create a simple, reliable, and
portable language.
• Java = Object-Oriented (all programs follows the concept of OOPS and classes
are created whenever you have to create any program)
• It does not uses Procedural Oriented Language.
Is JAVA Pure/Complete Object Oriented Language?
For a language to be called as a Pure Object Oriented Language, it must fulfill
following 7 properties:
1. Encapsulation/Data Hiding
2. Inheritance
3. Polymorphism
4. Abstraction
5. All predefined types are objects
6. All user defined types are objects
7. All operations performed on objects must be only through methods
exposed at the objects.
However, Out of above 7 properties, JAVA follows all except Property 5 and 7.
Because of this reason, JAVA is not a Pure/Complete Object Oriented Language.
Categories/Flavors of JAVA
• JAVA Programming languages is used in different application areas.
• JAVA can be used for :
1. Software Development (Core JAVA) (J2SE)
2. Website Development (Advanced JAVA) (J2EE)
3. Android Application Development (J2ME)
Why to Learn JAVA/ Features of JAVA
Following features of JAVA makes it a powerful Language:
• Simple and easy to Learn
• Platform Independent Language: because it does not depend on any type of platform. In
Java, programs are compiled into byte code and that byte code is platform-independent The
program can be executed in any Computer, no matter on which OS it was created and
compiled.
• Secure: Supports exception handling, programs run inside JVM (sandbox), support of
security APIs, compile time checking, etc.
• Compiled and Interpreted Language: Source code is compiled and converted to bytecode,
and then bytecode is given to interpreter (JVM) which generates the output.
• Robust: Because of concepts like Garbage Collector (destroys unused objects and frees
memory automatically), Exception Handling, etc.
• Huge Libraries and Frameworks Support
How JAVA Program Works?
• Java is compiled into the bytecode and then it is interpreted to
machine code.
• Java is both compiled as well as interpreted language.
How JAVA Program Works?
Java Installation
• Go to Google & type “Install JDK” (Installs Java JDK) (JAVA 17 is the
latest version).
• Go to Google & type “Install IntelliJ Idea” (Installs Java IDE)
• Jcreator, netbeans
• JDK – Java Development Kit = Collection of tools used for developing
java applications, and contains numerous development tools like
compilers, debuggers, etc.
• JRE – Java Runtime Environment = Helps in executing programs
developed in JAVA. It is used for implementation of JVM(Java Virtual
Machine)
Understanding the Structure of a JAVA Program
Main() Function is the entry point of your
java program.
JVM runs everything between the curly
braces { } of your main method.

Static allows us to run a


function without creating
the object of that class
How to Execute a Program in Java
Suppose, we have a java program with name Musharaf.java
We can execute the above program in following steps:
1. javac Musharaf.java (javac is the java compiler
which will take Musharaf.java as input, compile it).
After compilation of Musharaf.java, we will have a new file Musharaf.class
Fenil.class is the bytecode produced by the compiler.

2. java Musharaf
How to Execute a Program in Java
Basic Structure of a JAVA Program
A JAVA program consists of:

• Classes: Classes groups similar types of functions in them.


• Functions: For Code reusability, functions are created.
• Variables

• We use classes and functions by creating objects of these classes.


Important Points to Remember
• The extension of your Java Source code will be .java
• Every Java application has to have at least one class, and at least one
main method (not one main per class; just one main per application).
• We can have multiple classes in a JAVA project, but only one main
function per application.
Naming Conventions in Java

• For classes, we use Pascal Convention. (1st alphabet of every word is


capitalized).
For example: CarWashingService
AddTwoNumbers
• For functions, we uses camel Case Convention:
For Example: carWashingService
addTwoNumbers
Comments in JAVA

Comments are used for proper Documentation of Code and better


Readability of Code

// Single Line Comments


/* this
is
a
multiline comment */

You might also like