SlideShare a Scribd company logo
9801 200 111 | info@neosphere.com.np
9801 200 111 | info@neosphere.com.np
Application Fundamentals
9801 200 111 | info@neosphere.com.np
Types of Software
https://whatis.techtarget.com/definition/system-software
System Software
https://searchsoftwarequality.techtarget.com/definition/application
Application Software
Application
Software
Games, MS Office,
Browser etc.
System Software
Operating System,
Tools & Utilities,
Compilers
Hardware
Disk, CPU, RAM
9801 200 111 | info@neosphere.com.np
Types of
Application
Web Desktop Mobile
▪ Java
▪ .NET
▪ PHP
▪ Python
▪ Others
▪ Java
▪ .NET
▪ Python
▪ Others
▪ Android (java, Kotlin)
▪ iOS (Swift)
L
a
n
g
u
a
g
e
s
9801 200 111 | info@neosphere.com.np
We require
database to
store data
9801 200 111 | info@neosphere.com.np
Driver
We require JDBC (Java
Database Connectivity) Driver
to perform operation with
Databases
9801 200 111 | info@neosphere.com.np
It is intended to let application developers "write once,
run anywhere" (WORA), meaning that compiled Java
code can run on all platforms that support Java without
the need for recompilation.
9801 200 111 | info@neosphere.com.np
Java is Object Oriented
9801 200 111 | info@neosphere.com.np
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Compile: javac filename.java
Run: java ClassName
9801 200 111 | info@neosphere.com.np
javac HelloWorld.java
Compile:
java HelloWorld
Run:
9801 200 111 | info@neosphere.com.np
This is the entry point of our Java program. the main method has to have this
exact signature in order to be able to run our program.
public again means that anyone can access it.
static means that you can run this method without creating an instance of
HelloWorld.
void means that this method doesn't return any value.
main is the name of the method.
9801 200 111 | info@neosphere.com.np
• The HelloWorld.java file is known as source code file.
• It is compiled by invoking tool named javac.exe, which compiles the source code into a .class file.
• The .class file contains the bytecode which is interpreted by java.exe tool.
• java.exe interprets the bytecode and runs the program.
9801 200 111 | info@neosphere.com.np
Package in Java
A package in Java is used to group related classes. Think of it as a folder
in a file directory. We use packages to avoid name conflicts, and to
write a better maintainable code. Packages are divided into two
categories:
9801 200 111 | info@neosphere.com.np
Java Packages
• Built-in Packages (packages from the Java API)
• User-defined Packages (create your own packages)
9801 200 111 | info@neosphere.com.np
Importing packages
import package.name.Class; // Import a single class
import package.name.*; // Import the whole package
9801 200 111 | info@neosphere.com.np
Scanner Class in Java
import java.util.Scanner;
class MyClass {
public static void main(String[] args) {
Scanner myObj = new Scanner(System.in);
System.out.println("Enter username");
String userName = myObj.nextLine();
System.out.println("Username is: " + userName);
}
}
9801 200 111 | info@neosphere.com.np
To import a whole package,
end the statement with an asterisk sign (*).
import java.util.*;
9801 200 111 | info@neosphere.com.np
Methods in Java
• A method is a block of code which only runs when it is called.
• You can pass data, known as parameters, into a method.
9801 200 111 | info@neosphere.com.np
modifier returnType nameOfMethod (Parameter List) {
// method body
}
9801 200 111 | info@neosphere.com.np
Variables and Types
Although Java is object oriented, not all types are objects. It is built on top of basic variable types
called primitives.
List of all primitives in Java:
byte (number, 1 byte)
short (number, 2 bytes)
int (number, 4 bytes)
long (number, 8 bytes)
float (float number, 4 bytes)
double (float number, 8 bytes)
char (a character, 2 bytes)
boolean (true or false, 1 byte)
9801 200 111 | info@neosphere.com.np
Java is a strong typed language, which means variables need to
be defined before we use them.
int myNumber;
myNumber = 5;
9801 200 111 | info@neosphere.com.np
String is not a primitive. It's a real type, but Java has special treatment for String.
// Create a string with a constructor
String s1 = new String("Who let the dogs out?");
// Just using "" creates a string, so no need to write it the previous way.
String s2 = "Who who who who!";
// Java defined the operator + on strings to concatenate:
String s3 = s1 + s2;
int num = 5;
String s = "I have " + num + " cookies"; //Be sure not to use ""
with primitives.
Can also concat string to primitives:
9801 200 111 | info@neosphere.com.np
Operator
Operator in java is a symbol that is used to perform operations
9801 200 111 | info@neosphere.com.np
Operator Precedence
Operators Precedence
postfix expr++ expr--
unary ++expr --expr +expr -expr ~ !
multiplicative * / %
additive + -
shift << >> >>>
relational < > <= >= instanceof
equality == !=
bitwise AND &
bitwise exclusive OR ^
bitwise inclusive OR |
logical AND &&
logical OR ||
ternary ? :
assignment = += -= *= /= %= &= ^= |= <<= >>= >>>=
9801 200 111 | info@neosphere.com.np
Simple Assignment Operator
=
9801 200 111 | info@neosphere.com.np
Arithmetic Operators
+ Additive operator (also used for String concatenation)
- Subtraction operator
* Multiplication operator
/ Division operator
% Remainder operator
9801 200 111 | info@neosphere.com.np
Unary Operators
+ Unary plus operator; indicates positive value (numbers are
positive without this, however)
- Unary minus operator; negates an expression
++ Increment operator; increments a value by 1
-- Decrement operator; decrements a value by 1
! Logical complement operator; inverts the value of a boolean
9801 200 111 | info@neosphere.com.np
Equality and Relational Operators
== Equal to
!= Not equal to
> Greater than
>= Greater than or equal to
< Less than
<= Less than or equal to
9801 200 111 | info@neosphere.com.np
&& Conditional-AND
|| Conditional-OR
?: Ternary (shorthand for if-then-else statement)
9801 200 111 | info@neosphere.com.np
Bitwise and Bit Shift Operators
~ Unary bitwise complement
<< Signed left shift
>> Signed right shift
>>> Unsigned right shift
& Bitwise AND
^ Bitwise exclusive OR
| Bitwise inclusive OR
9801 200 111 | info@neosphere.com.np
Conditionals
Java uses boolean variables to evaluate conditions. The boolean values true
and false are returned when an expression is compared or evaluated. For
example:
int a = 4;
boolean b = a == 4;
if (b) {
System.out.println("It's true!");
}
9801 200 111 | info@neosphere.com.np
The if-then Statement
The if-then statement is the most basic of all the control flow statements
void applyBrakes() {
// the "if" clause: bicycle must be moving
if (isMoving){
// the "then" clause: decrease current speed
currentSpeed--;
}
}
9801 200 111 | info@neosphere.com.np
If this test evaluates to false (meaning that the bicycle is not in motion),
control jumps to the end of the if-then statement.
void applyBrakes() {
// the "if" clause: bicycle must be moving
if (isMoving){
// the "then" clause: decrease current speed
currentSpeed--;
}
}
9801 200 111 | info@neosphere.com.np
The if-then-else Statement
void applyBrakes() {
if (isMoving) {
currentSpeed--;
} else {
System.err.println("The bicycle has already stopped!");
}
}
9801 200 111 | info@neosphere.com.np
class IfElseDemo {
public static void main(String[] args) {
int testscore = 76;
char grade;
if (testscore >= 90) {
grade = 'A';
} else if (testscore >= 80) {
grade = 'B';
} else if (testscore >= 70) {
grade = 'C';
} else if (testscore >= 60) {
grade = 'D';
} else {
grade = 'F';
}
System.out.println("Grade = " + grade);
}
}
9801 200 111 | info@neosphere.com.np
The switch Statement
A switch works with the byte, short, char, and int primitive
data types.
It also works with enumerated types (discussed in Enum
Types), the String class, and a few special classes that wrap
certain primitive types: Character, Byte, Short, and Integer
9801 200 111 | info@neosphere.com.np
public class SwitchDemo {
public static void main(String[] args) {
int month = 8;
String monthString;
switch (month) {
case 1: monthString = "January";
break;
case 2: monthString = "February";
break;
case 3: monthString = "March";
break;
case 4: monthString = "April";
break;
9801 200 111 | info@neosphere.com.np
case 5: monthString = "May";
break;
case 6: monthString = "June";
break;
case 7: monthString = "July";
break;
case 8: monthString = "August";
break;
case 9: monthString = "September";
break;
case 10: monthString = "October";
break;
case 11: monthString = "November";
break;
case 12: monthString = "December";
break;
default: monthString = "Invalid month";
break;
}
System.out.println(monthString);
}
9801 200 111 | info@neosphere.com.np
• The body of a switch statement is known as a switch block.
• A statement in the switch block can be labeled with one or
more case or default labels.
• The switch statement evaluates its expression, then executes
all statements that follow the matching case label.
9801 200 111 | info@neosphere.com.np
The while and do-while Statements
The while statement continually executes a block of statements while a
particular condition is true. Its syntax can be expressed as:
while (expression) {
statement(s)
}
9801 200 111 | info@neosphere.com.np
The while statement evaluates expression, which must return a
boolean value.
9801 200 111 | info@neosphere.com.np
class WhileDemo {
public static void main(String[] args){
int count = 1;
while (count < 11) {
System.out.println("Count is: " + count);
count++;
}
}
}
9801 200 111 | info@neosphere.com.np
Do…while
class DoWhileDemo {
public static void main(String[] args){
int count = 1;
do {
System.out.println("Count is: " + count);
count++;
} while (count < 11);
}
}
9801 200 111 | info@neosphere.com.np
The for Statement
The for statement provides a compact way to iterate over a range of
values. Programmers often refer to it as the "for loop" because of the
way in which it repeatedly loops until a particular condition is satisfied.
9801 200 111 | info@neosphere.com.np
for (initialization; termination; increment) {
statement(s)
}
9801 200 111 | info@neosphere.com.np
class ForDemo {
public static void main(String[] args){
for(int i=1; i<11; i++){
System.out.println("Count is: " + i);
}
}
}
9801 200 111 | info@neosphere.com.np
Enhanced for
class EnhancedForDemo {
public static void main(String[] args){
int[] numbers = {1,2,3,4,5,6,7,8,9,10};
for (int item : numbers) {
System.out.println("Count is: " + item);
}
}
}

More Related Content

What's hot (20)

Python workshop session 6
Python workshop session 6Python workshop session 6
Python workshop session 6
Abdul Haseeb
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
vikram mahendra
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2
Amit Kapoor
 
Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)
Dharma Kshetri
 
INTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHONINTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHON
vikram mahendra
 
Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)
Saket Pathak
 
OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2
vikram mahendra
 
Functions in C
Functions in CFunctions in C
Functions in C
Princy Nelson
 
C aptitude scribd
C aptitude scribdC aptitude scribd
C aptitude scribd
Amit Kapoor
 
C program
C programC program
C program
Komal Singh
 
18CSS101J PROGRAMMING FOR PROBLEM SOLVING
18CSS101J PROGRAMMING FOR PROBLEM SOLVING18CSS101J PROGRAMMING FOR PROBLEM SOLVING
18CSS101J PROGRAMMING FOR PROBLEM SOLVING
GOWSIKRAJAP
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
nikshaikh786
 
Arrays
ArraysArrays
Arrays
Saranya saran
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
JAYA
 
Unit 3
Unit 3 Unit 3
Unit 3
GOWSIKRAJAP
 
8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointers
MomenMostafa
 
C programs
C programsC programs
C programs
Vikram Nandini
 
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
Make Mannan
 
Functions
FunctionsFunctions
Functions
Swarup Kumar Boro
 
Advance python programming
Advance python programming Advance python programming
Advance python programming
Jagdish Chavan
 
Python workshop session 6
Python workshop session 6Python workshop session 6
Python workshop session 6
Abdul Haseeb
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
vikram mahendra
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2
Amit Kapoor
 
Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)
Dharma Kshetri
 
INTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHONINTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHON
vikram mahendra
 
Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)
Saket Pathak
 
OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2
vikram mahendra
 
C aptitude scribd
C aptitude scribdC aptitude scribd
C aptitude scribd
Amit Kapoor
 
18CSS101J PROGRAMMING FOR PROBLEM SOLVING
18CSS101J PROGRAMMING FOR PROBLEM SOLVING18CSS101J PROGRAMMING FOR PROBLEM SOLVING
18CSS101J PROGRAMMING FOR PROBLEM SOLVING
GOWSIKRAJAP
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
nikshaikh786
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
JAYA
 
8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointers
MomenMostafa
 
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
Make Mannan
 
Advance python programming
Advance python programming Advance python programming
Advance python programming
Jagdish Chavan
 

Similar to Java Programming Workshop (20)

Java
JavaJava
Java
Ashen Disanayaka
 
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysUnit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
DevaKumari Vijay
 
Java platform
Java platformJava platform
Java platform
Visithan
 
Java class 1
Java class 1Java class 1
Java class 1
Edureka!
 
Introduction to Java Programming Part 2
Introduction to Java Programming Part 2Introduction to Java Programming Part 2
Introduction to Java Programming Part 2
university of education,Lahore
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
HCMUTE
 
JPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingJPC#8 Introduction to Java Programming
JPC#8 Introduction to Java Programming
Pathomchon Sriwilairit
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
Ashita Agrawal
 
Bt0074 oops with java
Bt0074 oops with javaBt0074 oops with java
Bt0074 oops with java
Techglyphs
 
Android webinar class_java_review
Android webinar class_java_reviewAndroid webinar class_java_review
Android webinar class_java_review
Edureka!
 
Fundamental programming structures in java
Fundamental programming structures in javaFundamental programming structures in java
Fundamental programming structures in java
Shashwat Shriparv
 
data types.pdf
data types.pdfdata types.pdf
data types.pdf
HarshithaGowda914171
 
DISE - Windows Based Application Development in Java
DISE - Windows Based Application Development in JavaDISE - Windows Based Application Development in Java
DISE - Windows Based Application Development in Java
Rasan Samarasinghe
 
java tutorial 2
 java tutorial 2 java tutorial 2
java tutorial 2
Tushar Desarda
 
Learning core java
Learning core javaLearning core java
Learning core java
Abhay Bharti
 
MODULE_2_Operators.pptx
MODULE_2_Operators.pptxMODULE_2_Operators.pptx
MODULE_2_Operators.pptx
VeerannaKotagi1
 
Javascript
JavascriptJavascript
Javascript
Sheldon Abraham
 
Chapter 2&3 (java fundamentals and Control Structures).ppt
Chapter 2&3 (java fundamentals and Control Structures).pptChapter 2&3 (java fundamentals and Control Structures).ppt
Chapter 2&3 (java fundamentals and Control Structures).ppt
henokmetaferia1
 
JAVA programming language made easy.pptx
JAVA programming language made easy.pptxJAVA programming language made easy.pptx
JAVA programming language made easy.pptx
Sunila31
 
UNIT – 2 Features of java- (Shilpa R).pptx
UNIT – 2 Features of java- (Shilpa R).pptxUNIT – 2 Features of java- (Shilpa R).pptx
UNIT – 2 Features of java- (Shilpa R).pptx
shilpar780389
 
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysUnit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
DevaKumari Vijay
 
Java platform
Java platformJava platform
Java platform
Visithan
 
Java class 1
Java class 1Java class 1
Java class 1
Edureka!
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
HCMUTE
 
JPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingJPC#8 Introduction to Java Programming
JPC#8 Introduction to Java Programming
Pathomchon Sriwilairit
 
Bt0074 oops with java
Bt0074 oops with javaBt0074 oops with java
Bt0074 oops with java
Techglyphs
 
Android webinar class_java_review
Android webinar class_java_reviewAndroid webinar class_java_review
Android webinar class_java_review
Edureka!
 
Fundamental programming structures in java
Fundamental programming structures in javaFundamental programming structures in java
Fundamental programming structures in java
Shashwat Shriparv
 
DISE - Windows Based Application Development in Java
DISE - Windows Based Application Development in JavaDISE - Windows Based Application Development in Java
DISE - Windows Based Application Development in Java
Rasan Samarasinghe
 
Learning core java
Learning core javaLearning core java
Learning core java
Abhay Bharti
 
Chapter 2&3 (java fundamentals and Control Structures).ppt
Chapter 2&3 (java fundamentals and Control Structures).pptChapter 2&3 (java fundamentals and Control Structures).ppt
Chapter 2&3 (java fundamentals and Control Structures).ppt
henokmetaferia1
 
JAVA programming language made easy.pptx
JAVA programming language made easy.pptxJAVA programming language made easy.pptx
JAVA programming language made easy.pptx
Sunila31
 
UNIT – 2 Features of java- (Shilpa R).pptx
UNIT – 2 Features of java- (Shilpa R).pptxUNIT – 2 Features of java- (Shilpa R).pptx
UNIT – 2 Features of java- (Shilpa R).pptx
shilpar780389
 
Ad

More from neosphere (7)

Digital Marketing in Business
Digital Marketing in BusinessDigital Marketing in Business
Digital Marketing in Business
neosphere
 
CCNP Presentation- neosphere
CCNP Presentation- neosphereCCNP Presentation- neosphere
CCNP Presentation- neosphere
neosphere
 
Digital marketing
Digital marketingDigital marketing
Digital marketing
neosphere
 
Career in Software Development
Career in Software Development  Career in Software Development
Career in Software Development
neosphere
 
Building career in Information Technology
Building career in Information TechnologyBuilding career in Information Technology
Building career in Information Technology
neosphere
 
Career as network specialist
Career as network specialistCareer as network specialist
Career as network specialist
neosphere
 
Career in Ethical Hacking
Career in Ethical Hacking Career in Ethical Hacking
Career in Ethical Hacking
neosphere
 
Digital Marketing in Business
Digital Marketing in BusinessDigital Marketing in Business
Digital Marketing in Business
neosphere
 
CCNP Presentation- neosphere
CCNP Presentation- neosphereCCNP Presentation- neosphere
CCNP Presentation- neosphere
neosphere
 
Digital marketing
Digital marketingDigital marketing
Digital marketing
neosphere
 
Career in Software Development
Career in Software Development  Career in Software Development
Career in Software Development
neosphere
 
Building career in Information Technology
Building career in Information TechnologyBuilding career in Information Technology
Building career in Information Technology
neosphere
 
Career as network specialist
Career as network specialistCareer as network specialist
Career as network specialist
neosphere
 
Career in Ethical Hacking
Career in Ethical Hacking Career in Ethical Hacking
Career in Ethical Hacking
neosphere
 
Ad

Recently uploaded (20)

Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18
Celine George
 
Black and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdfBlack and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdf
AnnasofiaUrsini
 
Optimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptxOptimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptx
UrmiPrajapati3
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdfUnit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptxjune 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
 
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
Quiz Club of PSG College of Arts & Science
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptxSEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
PoojaSen20
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptxDiptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Arshad Shaikh
 
What are the benefits that dance brings?
What are the benefits that dance brings?What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
Quiz Club of PSG College of Arts & Science
 
Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...
Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...
Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...
National Information Standards Organization (NISO)
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 SlidesHow to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
Parenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independenceParenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independence
Pooky Knightsmith
 
Hemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptxHemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptx
Arshad Shaikh
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18
Celine George
 
Black and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdfBlack and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdf
AnnasofiaUrsini
 
Optimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptxOptimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptx
UrmiPrajapati3
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdfUnit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptxjune 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptxSEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
PoojaSen20
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptxDiptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Arshad Shaikh
 
What are the benefits that dance brings?
What are the benefits that dance brings?What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 SlidesHow to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
Parenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independenceParenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independence
Pooky Knightsmith
 
Hemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptxHemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptx
Arshad Shaikh
 

Java Programming Workshop

  • 2. 9801 200 111 | [email protected] Application Fundamentals
  • 3. 9801 200 111 | [email protected] Types of Software https://whatis.techtarget.com/definition/system-software System Software https://searchsoftwarequality.techtarget.com/definition/application Application Software Application Software Games, MS Office, Browser etc. System Software Operating System, Tools & Utilities, Compilers Hardware Disk, CPU, RAM
  • 4. 9801 200 111 | [email protected] Types of Application Web Desktop Mobile ▪ Java ▪ .NET ▪ PHP ▪ Python ▪ Others ▪ Java ▪ .NET ▪ Python ▪ Others ▪ Android (java, Kotlin) ▪ iOS (Swift) L a n g u a g e s
  • 5. 9801 200 111 | [email protected] We require database to store data
  • 6. 9801 200 111 | [email protected] Driver We require JDBC (Java Database Connectivity) Driver to perform operation with Databases
  • 7. 9801 200 111 | [email protected] It is intended to let application developers "write once, run anywhere" (WORA), meaning that compiled Java code can run on all platforms that support Java without the need for recompilation.
  • 8. 9801 200 111 | [email protected] Java is Object Oriented
  • 9. 9801 200 111 | [email protected] public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } } Compile: javac filename.java Run: java ClassName
  • 10. 9801 200 111 | [email protected] javac HelloWorld.java Compile: java HelloWorld Run:
  • 11. 9801 200 111 | [email protected] This is the entry point of our Java program. the main method has to have this exact signature in order to be able to run our program. public again means that anyone can access it. static means that you can run this method without creating an instance of HelloWorld. void means that this method doesn't return any value. main is the name of the method.
  • 12. 9801 200 111 | [email protected] • The HelloWorld.java file is known as source code file. • It is compiled by invoking tool named javac.exe, which compiles the source code into a .class file. • The .class file contains the bytecode which is interpreted by java.exe tool. • java.exe interprets the bytecode and runs the program.
  • 13. 9801 200 111 | [email protected] Package in Java A package in Java is used to group related classes. Think of it as a folder in a file directory. We use packages to avoid name conflicts, and to write a better maintainable code. Packages are divided into two categories:
  • 14. 9801 200 111 | [email protected] Java Packages • Built-in Packages (packages from the Java API) • User-defined Packages (create your own packages)
  • 15. 9801 200 111 | [email protected] Importing packages import package.name.Class; // Import a single class import package.name.*; // Import the whole package
  • 16. 9801 200 111 | [email protected] Scanner Class in Java import java.util.Scanner; class MyClass { public static void main(String[] args) { Scanner myObj = new Scanner(System.in); System.out.println("Enter username"); String userName = myObj.nextLine(); System.out.println("Username is: " + userName); } }
  • 17. 9801 200 111 | [email protected] To import a whole package, end the statement with an asterisk sign (*). import java.util.*;
  • 18. 9801 200 111 | [email protected] Methods in Java • A method is a block of code which only runs when it is called. • You can pass data, known as parameters, into a method.
  • 19. 9801 200 111 | [email protected] modifier returnType nameOfMethod (Parameter List) { // method body }
  • 20. 9801 200 111 | [email protected] Variables and Types Although Java is object oriented, not all types are objects. It is built on top of basic variable types called primitives. List of all primitives in Java: byte (number, 1 byte) short (number, 2 bytes) int (number, 4 bytes) long (number, 8 bytes) float (float number, 4 bytes) double (float number, 8 bytes) char (a character, 2 bytes) boolean (true or false, 1 byte)
  • 21. 9801 200 111 | [email protected] Java is a strong typed language, which means variables need to be defined before we use them. int myNumber; myNumber = 5;
  • 22. 9801 200 111 | [email protected] String is not a primitive. It's a real type, but Java has special treatment for String. // Create a string with a constructor String s1 = new String("Who let the dogs out?"); // Just using "" creates a string, so no need to write it the previous way. String s2 = "Who who who who!"; // Java defined the operator + on strings to concatenate: String s3 = s1 + s2; int num = 5; String s = "I have " + num + " cookies"; //Be sure not to use "" with primitives. Can also concat string to primitives:
  • 23. 9801 200 111 | [email protected] Operator Operator in java is a symbol that is used to perform operations
  • 24. 9801 200 111 | [email protected] Operator Precedence Operators Precedence postfix expr++ expr-- unary ++expr --expr +expr -expr ~ ! multiplicative * / % additive + - shift << >> >>> relational < > <= >= instanceof equality == != bitwise AND & bitwise exclusive OR ^ bitwise inclusive OR | logical AND && logical OR || ternary ? : assignment = += -= *= /= %= &= ^= |= <<= >>= >>>=
  • 25. 9801 200 111 | [email protected] Simple Assignment Operator =
  • 26. 9801 200 111 | [email protected] Arithmetic Operators + Additive operator (also used for String concatenation) - Subtraction operator * Multiplication operator / Division operator % Remainder operator
  • 27. 9801 200 111 | [email protected] Unary Operators + Unary plus operator; indicates positive value (numbers are positive without this, however) - Unary minus operator; negates an expression ++ Increment operator; increments a value by 1 -- Decrement operator; decrements a value by 1 ! Logical complement operator; inverts the value of a boolean
  • 28. 9801 200 111 | [email protected] Equality and Relational Operators == Equal to != Not equal to > Greater than >= Greater than or equal to < Less than <= Less than or equal to
  • 29. 9801 200 111 | [email protected] && Conditional-AND || Conditional-OR ?: Ternary (shorthand for if-then-else statement)
  • 30. 9801 200 111 | [email protected] Bitwise and Bit Shift Operators ~ Unary bitwise complement << Signed left shift >> Signed right shift >>> Unsigned right shift & Bitwise AND ^ Bitwise exclusive OR | Bitwise inclusive OR
  • 31. 9801 200 111 | [email protected] Conditionals Java uses boolean variables to evaluate conditions. The boolean values true and false are returned when an expression is compared or evaluated. For example: int a = 4; boolean b = a == 4; if (b) { System.out.println("It's true!"); }
  • 32. 9801 200 111 | [email protected] The if-then Statement The if-then statement is the most basic of all the control flow statements void applyBrakes() { // the "if" clause: bicycle must be moving if (isMoving){ // the "then" clause: decrease current speed currentSpeed--; } }
  • 33. 9801 200 111 | [email protected] If this test evaluates to false (meaning that the bicycle is not in motion), control jumps to the end of the if-then statement. void applyBrakes() { // the "if" clause: bicycle must be moving if (isMoving){ // the "then" clause: decrease current speed currentSpeed--; } }
  • 34. 9801 200 111 | [email protected] The if-then-else Statement void applyBrakes() { if (isMoving) { currentSpeed--; } else { System.err.println("The bicycle has already stopped!"); } }
  • 35. 9801 200 111 | [email protected] class IfElseDemo { public static void main(String[] args) { int testscore = 76; char grade; if (testscore >= 90) { grade = 'A'; } else if (testscore >= 80) { grade = 'B'; } else if (testscore >= 70) { grade = 'C'; } else if (testscore >= 60) { grade = 'D'; } else { grade = 'F'; } System.out.println("Grade = " + grade); } }
  • 36. 9801 200 111 | [email protected] The switch Statement A switch works with the byte, short, char, and int primitive data types. It also works with enumerated types (discussed in Enum Types), the String class, and a few special classes that wrap certain primitive types: Character, Byte, Short, and Integer
  • 37. 9801 200 111 | [email protected] public class SwitchDemo { public static void main(String[] args) { int month = 8; String monthString; switch (month) { case 1: monthString = "January"; break; case 2: monthString = "February"; break; case 3: monthString = "March"; break; case 4: monthString = "April"; break;
  • 38. 9801 200 111 | [email protected] case 5: monthString = "May"; break; case 6: monthString = "June"; break; case 7: monthString = "July"; break; case 8: monthString = "August"; break; case 9: monthString = "September"; break; case 10: monthString = "October"; break; case 11: monthString = "November"; break; case 12: monthString = "December"; break; default: monthString = "Invalid month"; break; } System.out.println(monthString); }
  • 39. 9801 200 111 | [email protected] • The body of a switch statement is known as a switch block. • A statement in the switch block can be labeled with one or more case or default labels. • The switch statement evaluates its expression, then executes all statements that follow the matching case label.
  • 40. 9801 200 111 | [email protected] The while and do-while Statements The while statement continually executes a block of statements while a particular condition is true. Its syntax can be expressed as: while (expression) { statement(s) }
  • 41. 9801 200 111 | [email protected] The while statement evaluates expression, which must return a boolean value.
  • 42. 9801 200 111 | [email protected] class WhileDemo { public static void main(String[] args){ int count = 1; while (count < 11) { System.out.println("Count is: " + count); count++; } } }
  • 43. 9801 200 111 | [email protected] Do…while class DoWhileDemo { public static void main(String[] args){ int count = 1; do { System.out.println("Count is: " + count); count++; } while (count < 11); } }
  • 44. 9801 200 111 | [email protected] The for Statement The for statement provides a compact way to iterate over a range of values. Programmers often refer to it as the "for loop" because of the way in which it repeatedly loops until a particular condition is satisfied.
  • 45. 9801 200 111 | [email protected] for (initialization; termination; increment) { statement(s) }
  • 46. 9801 200 111 | [email protected] class ForDemo { public static void main(String[] args){ for(int i=1; i<11; i++){ System.out.println("Count is: " + i); } } }
  • 47. 9801 200 111 | [email protected] Enhanced for class EnhancedForDemo { public static void main(String[] args){ int[] numbers = {1,2,3,4,5,6,7,8,9,10}; for (int item : numbers) { System.out.println("Count is: " + item); } } }