CSE 1018
Problem Solving and
Object Oriented
Programming in Java
Dr. Christy Jackson J,
Associate Professor,
School of Computer Science and
Engineering[SCOPE],
Vellore Institute of Technology,
Chennai - 600 127, India.
1
2
Please make sure you are
sitting in the correct meeting
Welcome
CSE1018 Problem Solving and
Object-Oriented Programming
in Java - Prof. Christy Jackson.
Very Little About Me
• Name: Dr. J. Christy Jackson
• B.E (CSE)- Karunya University, Coimbatore
• MS(IT)- Griffith University, Brisbane, Australia
• PhD – VIT Chennai
• Worked as an Oracle SQL forms and reports
developer and now in VIT
• Email: [email protected]
• Phone: +91 8939109547 ( WhatsApp is appreciated)
• Location: AB1 4th Floor Annexure Cabin No: 20
3
Class Timings
L5+L6 – 11:40 – 1:20 PM L23+24 – 11:40 – 1:20 PM
Tuesday
Monday Thursday
L37+38 – 2:00 – 3:40 PM
4
TextBook
• Herbert Schildt, The Complete Reference
– java, Tata McGraw-Hill Education, 10th
Edition, 2017
• Paul J. Deitel, Harvey Deitel, Java SE8 for
programmers (Deitel Developer Series)
3rd Edition, 2014
• Y. Daniel Liang, Introduction to Java
Programming-Comprehensive Version-
10th Edition, Pearson Ltd, 2015.
5
Syllabus
6
7
8
9
10
Assessment
11
Guidelines for a Successful Java Programming
Course
• Try to be on time
• Attendance will become a major issue if you do
not maintain 75%
• Be attentive in the class and please DO NOT get
distracted during the lecture
• Learn Programming (No other choice)
• Practise
• Do Not Copy Code
• No Mobile phones inside the lab
12
WhatsApp Group
Will be created after add/drop
13
Java Basics
14
JAVA - Introduction
Development of each programming language is based
on a fact: there is a need to solve a problem that was
not resolved by previous programming languages.
Fortran - used to write efficient programs for scientific
problems, but it was not good for system code.
Basic - easy to understand but not robust to write big
programs.
Assembly language - powerful for writing efficient
programs, but it was not easy to remember and
execution.
15
JAVA - Introduction
• Programming languages such as Cobol and Fortran
do not have structural principles.
• They use the goto statement to control the flow of
the program.
• C language was invented in 1970, to replace the
assembly language and to create a structured,
effective, and high-level language
• C++ came with object-oriented programming (OOP)
features.
• C++ is the extension of C language which has been
used extensively.
• It is a powerful modern language that includes the
power and simplicity of C and the characteristics of
OOP.
16
• James Gosling, Patrick Naughton, Chris
Warth, Mike Sheridan, and Ed Frank initiated
the Java language project in June 1991.
• The idea was to develop a language that was
platform-independent and which could
create embedded software for consumer
History of electronic devices.
Java • It took 18 months to develop and had an
initial name as Oak.
• Renamed to Java in 1995, due to copyright
issues.
• Java originally developed by James Gosling
at Sun Microsystems and released in 1995.
17
JAVA
Java is a popular programming language, created in 1995.
It is owned by Oracle, and more than 3 billion devices run Java.
Mobile applications (specially Android apps),
Desktop applications, Web applications, Web
It is used for: servers and application servers, Games, Database
connection, And much, much more!
18
Uses
Java works on different platforms (Windows, Mac, Linux, Raspberry
Pi, etc.)
It is one of the most popular programming language in the world
It is open-source and free
It has a huge community support (tens of millions of developers)
Java is an object oriented language which gives a clear structure to
programs and allows code to be reused, lowering development
costs
As Java is close to C++ and C#, it makes it easy for programmers to
switch to Java or vice versa
19
• Familiar, Simple, and Small
• Compiled and Interpreted
Feature • Platform-Independent and Portable
• Object-Oriented
s of • Robust and Secure
• Distributed
Java • Multithreaded and Interactive
• High Performance
• Dynamic and Extensible 20
• Java compiler translates source code into the byte code
instructions.
Architecture • Java interpreter converts the byte code instructions to machine
code.
21
Architecture
• Java Compiler - Java source code (file with extension .java) to byte code (file
with extension .class).
• Byte code - an intermediate form, closer to machine representation.
• A interpreter (virtual machine) on any target platform interprets the
bytecode.
• Porting the java system to any new platform involves writing an interpreter.
• The interpreter will figure out what the equivalent machine dependent code
to run
22
Architecture
• Byte code allows Java to solve both security and portability problems.
• Output of a Java compiler is not executable code but it is the Bytecode.
• Highly optimized set of instructions designed to be executed by the Java
run-time system, which is called the Java Virtual Machine (JVM).
• JVM is an interpreter for bytecode.
• Java program is executed by JVM helps solve major problems associated
with downloading programs over the Internet.
• Translating a Java program into bytecode helps makes it much easier to run
a program in a wide variety of environments.
• Only the JVM needs to be implemented for each platform.
23
Why to learn Java? In Java, everything is an Object. Java
Object Oriented can be easily extended since it is
based on the Object model.
Byte code is distributed over the
web and interpreted by the Virtual
Platform Independent Machine (JVM) on whichever
platform it is being run on.
24
Simple
With Java's secure feature it enables
to develop virus-free, tamper-free
Secure systems. Authentication techniques
are based on public-key encryption.
25
Architecture-neutral Portable Robust
Java compiler generates an Being architecture-neutral and Java makes an effort to eliminate
architecture-neutral object file having no implementation error prone situations by
format, which makes the compiled dependent aspects of the emphasizing mainly on compile time
code executable on many processors, specification makes Java portable. error checking and runtime checking.
with the presence of Java runtime Compiler in Java is written in ANSI C
system. with a clean portability boundary
JVM
JVM is the one that
JVM(Java Virtual Machine)
actually calls the main JVM is a part of JRE(Java
acts as a run-time engine
method present in a java Runtime Environment).
to run Java applications.
code.
26
When we compile a .java
file, .class files(contains
Java applications are
byte-code) with the same
called WORA (Write Once
class names present
Run Anywhere).
in .java file are generated
by the Java compiler.
Platform Dependent
myprog.c myprog.exe
gcc machine code
C source code
OS/Hardware
Platform Independent
myprog.java myprog.class
javac bytecode
Java source code
JVM
OS/Hardware
27
Java Install
C:\Users\Your Name>java -version
Setup for Windows
•To install Java on Windows:
•Go to "System Properties" (Can be found on Control Panel > System and Security > System >
Advanced System Settings)
•Click on the "Environment variables" button under the "Advanced" tab
•Then, select the "Path" variable in System variables and click on the "Edit" button
•Click on the "New" button and add the path where Java is installed, followed by \bin. By default,
Java is installed in C:\Program Files\Java\jdk-11.0.1 (If nothing else was specified when you installed
it). In that case, You will have to add a new path with: C:\Program Files\Java\jdk-11.0.1\bin
Then, click "OK", and save the settings
•At last, open Command Prompt (cmd.exe) and type java -version to see if Java is running on your
machine
28
Software Requirements
• Java Development Kit (JDK) – JDK 20
• Integrated Development Environment (IDE)
• NetBeans
• Eclipse
• Command Prompt
29
public class DemoMain {
Let’s Start… public static void main(String[] args) {
System.out.println("Hello All! Welcome to
JAVA Programming.");
}
}
• Output:
Hello All! Welcome to JAVA Programming.
30
• https://www.oracle.com/in/java/technologie
Link s/javase-downloads.html.
• https://www.javatpoint.com/how-to-downlo
ad-java
31
Herbert Schildt, The Complete Reference – java, Tata
McGraw-Hill Education, 10th Edition, 2017
Paul J. Deitel, Harvey Deitel, Java SE8 for
programmers (Deitel Developer Series) 3rd Edition,
2014
Y. Daniel Liang, Introduction to Java Programming-
Comprehensive Version-10th Edition, Pearson Ltd,
References
2015
Kathy Sierra, Bert Bates , Head First Java, 2nd Edition
2nd Edition , O'Reilly Media; 2nd edition (February
19, 2005)
Cay S. Horstmann, Core Java Volume I—
Fundamentals 9th Edition, Prentice Hall; 9 edition
(December 7, 2012) Joshua Bloch, Effective Java-2nd
Edition, Addison-Wesley; (May 28, 2008).
https://www.javatpoint.com/java-tutorial
32