0% found this document useful (0 votes)
9 views22 pages

Institute: Uie Department: Cse: Bachelor of Engineering (Computer Science & Engineering)

The document presents a lecture on Java fundamentals, covering topics such as Java APIs, keywords, identifiers, data types, and operators. It includes examples and quizzes to reinforce understanding of concepts like class, object, methods, and variable types. The session aims to empower learners with essential knowledge for programming in Java.

Uploaded by

thakurrohit5859
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views22 pages

Institute: Uie Department: Cse: Bachelor of Engineering (Computer Science & Engineering)

The document presents a lecture on Java fundamentals, covering topics such as Java APIs, keywords, identifiers, data types, and operators. It includes examples and quizzes to reinforce understanding of concepts like class, object, methods, and variable types. The session aims to empower learners with essential knowledge for programming in Java.

Uploaded by

thakurrohit5859
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

INSTITUTE : UIE

DEPARTMENT : CSE
Bachelor of Engineering (Computer Science &
Engineering)

Object Oriented Programming using Java


(23CSP-202 )
TOPIC OF PRESENTATION:
Java Fundamentals Prepared by:
Bhavneet Kaur
Master Subject
Coordinator

DISCOVER . LEARN . EMPOWER


Lecture
Objectives

In this lecture, we will


discuss:
• About various java
API’s
• Various java keywords
• Identifiers and data
types are discussed
along with their
programs.
• Operators
2
JAVA API

• Java application programming interface (API) is a list of all classes that are part of
the Java development kit (JDK).
• It includes all Java packages, classes, and interfaces, along with their methods, fields,
and constructors.
• These prewritten classes provide a tremendous amount of Built-in Packages.
• The Java API is a library of prewritten classes which contains components for managing
input, database programming.
• The library is divided into packages and classes i.e you can either import a single class
or a whole package that contain all the classes that belong to the specified package.
• To use a class or a package from the library, you need to use the import keyword.
Understanding of .class file
concept
Sample.java file contains class A, B and C.
How many .class files will be created after compiling Sample.java?

Sample.java
class A { What is your
observation?
void m1() { }
}
class B {
void m2() { }
}
class C {
void m3() { }
}
Difference between class,
object, methods, and instance
variables?

Object - Objects have states Methods - A method is


Instance - Each object has its
and behaviors. Example: A Class - A class can be defined basically a behavior. A class
unique set of instance
dog has states - color, name, as a template/blueprint that can contain many methods.
variables. An object's state is
breed as well as behavior describes the behavior/state It is in methods where the
created by the values
such as wagging their tail, that the object of its type logics are written, data is
assigned to these instance
barking, eating. An object is supports. manipulated and all the
variables.
an instance of a class. actions are executed
Analyze the below program and answer
What will be the result if you try to compile and execute
the following program ?
Sample.java
class Sample {
public static void main() {
System.out.println(“Welcome”);
}
}
a. Compilation Error
b. Runtime Error
c. The program compiles and executes successfully but
prints
nothing.
d. It will print “Welcome”
Accessing numeric
command line arguments
class Simple {
A Java application can accept any number of
static public void main(String[] args) { arguments from the command line.
int i1 = Integer.parseInt(args[0]);
Command-line arguments allow the user to
int i2 = Integer.parseInt(args[1]); affect the operation of an application for one
System.out.println(i1+i2); invocation.
} If your program needs to support a numeric
} command-line argument, it must convert
a String argument that represents a number,
When we compile the above code
such as "34", to a number.
successfully and execute it as Java
Simple 10 20, the output will be 30.
Java Keywords
• Java has a set of keywords that are reserved words that cannot be used as
variables, methods, classes, or any other identifiers.
• Example break, abstract, byte, Boolean etc
• True, false, and null are not keywords, but they are literals and reserved
words that cannot be used as identifiers.
Which statement is true?

(a) new and delete are keywords in the Java language.

(b) try, catch, and thrown are keywords in the Java language.

(c) static, unsigned, and long are keywords in the Java language.

(d) exit, class, and while are keywords in the Java language.

(e) return, goto, and default are keywords in the Java language.

(f) for, while, and next are keywords in the Java language.

9
Java Operators
An operator is a symbol that tells the
compiler to perform a specific
mathematical or logical
manipulation. Arithmetic

Bitwise

Classes of
Operators
Logical

Relational
ARITHMATIC OPERATORS

RELATIONAL OPERATORS

LOGICAL OPERATORS

11
Can you identify the output for the
below code?

Source:
Java™
A Beginner’s
Guide 12
Sixth Edition ,
Identifiers in java
• In programming languages, identifiers are used for
identification purpose.
• In Java, an identifier can be a class name, method name,
variable name or a label.
• For example :public class Test { public static void main(String[]
args) { int a = 20; } }

Which of the following can be used in a Java program as


identifiers? Check all of the identifiers that are legal.
1. sum_of_data
2. AnnualSalary
3. _average
4. 42isThesolution
5. B4
6. ABC
7. for
8. println
9. "hello"
10. first-name
Answer:1 2 3 5 6 8
Lets Brief!
1. What is null in Java.
The null is not a keyword. null is a literal as true or false
2. Can a digit form the first character of an identifier?
No. Only characters are allowed. However, they may be used after the first
character.
3. Explain var keyword in Java.
var keyword is introduced in Java 10 to enhance the Java Language to extend type
inference to declarations of local variables with initializers.
var map = new HashMap<String, Integer>();
Difference between local, instance and
static variable

• Tied to a method
Local Variables • Scope of a local variable is within the method

Instance Variables • Tied to an object


(Non-static) • Scope of an instance variable is the whole class

• Tied to a class
Static Variables • Shared by all instances of a class
Data Types
Understanding of data type concepts

What will be the result, if we try to compile and execute the following??
code?
class Test {
public static void main(String [ ] ar) {
byte b=128;
System.out.println(b);
}
}
QUIZ
1. Which of the following do not denote a primitive data value in Java? Select the
two correct answers.
(a) "t"
(b) 'k‘
(c) 50.5F
(d) "hello"
(e) false 2.5
QUIZ
2. Which of the following primitive data types are not integer types? Select the
three correct answers.
(a) boolean
(b) byte
(c) float
(d) short
(e) double
Summary:

In this session, you were able to :


• Learn about Java API’S, its features
• Understand Java keywords, identifiers.
• Various data types are also discussed
References:
Books:

1. Balaguruswamy, Java.
2. A Primer, E.Balaguruswamy, Programming
with Java, Tata McGraw Hill Companies
3. John P. Flynt Thomson, Java Programming.

Video Lectures :
https://www.youtube.com/watch?v=0MFC_Vw
9NxY

E-book :
https://www.learnjavaonline.org/
THANK YOU

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy