0% found this document useful (0 votes)
17 views17 pages

OOPJ Workbook

Uploaded by

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

OOPJ Workbook

Uploaded by

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

M.S.P.M.

’s
Deogiri Institute of Engineering and Management
Studies, Aurangabad
Department of Computer Science
and Engineering

Work-Book
On
Object Oriented Programming in
Java
Introduction to Programming Languages
1. What is Programming Language (PL)?
2. Classification of PL
3. Why to learn Java in 2021
4. Introduction to Java
5. Recommended Resources

1. What is Programming Language (PL)?


A programming language is a set of commands, instructions, and other syntax use to
create a software program. Languages that programmers use to write code are called
"high-level languages." This code can be compiled into a "low-level language," which is
recognized directly by the computer hardware.

2. Classification of PL

Workbook on Object Oriented Programming in Java


2
Prepared By: Ms. Priyanka B. Dhas | Dept of CSE | DIEMS
3.Why to learn Java in 2021 and where it is
Used?

• Java is a general-purpose, object- • Following diagram shows some


applications of java.
oriented, high-level programming
language with several features.
• Java is powerful, diverse, scalable,
and fun.
• Java is Java's beginner-friendly and
competitive edge nature.
• Java is used to develop enterprise-
level applications for video games
and mobile apps, as well as to
create web-based applications with
JSP (Java Server Pages). When used
online, Java allows applets to be
downloaded and used through a
browser, which can then perform a
function not normally available. • Programs that use or are written in
• Updated features Java include Adobe Creative Suite,
• https://www.ryadel.com/en/java- Eclipse, Lotus Notes, Minecraft and
programming-language-useful-2021-
developer-software/ OpenOffice.
• https://dzone.com/articles/is-java-still- • Java web development companies in
relevant-in-2021-1
India
• Best java software development
companies:

Workbook on Object Oriented Programming in Java


3
Prepared By: Ms. Priyanka B. Dhas | Dept of CSE | DIEMS
4.Introduction to Java

• 4.1 What is Java Programming Language?


• Java is a widely used programming language and is designed
for the distributed environment of internet. It is a general-
purpose programming language that is concurrent, class-based, and
object-oriented.
• It is free to access and we can run it on all the platforms. Java
follows the principle of WORA (Write Once, Run Anywhere), and
is platform-independent. It is also simple and easy to learn. If
you want to print say (“Hello, World!”), you would type:
• public class Hello {
public static void main (String [] args) {
System.out.println("Hello, World!");
}
}
• Every code in java is wrapped inside a class. You are allowed
to write as many as methods under a class but out of class
can not write single line of code.
• Data security is the priority in java instead of flow of the
code.
• Java strongly supports object-oriented concept.

Workbook on Object Oriented Programming in Java


4
Prepared By: Ms. Priyanka B. Dhas | Dept of CSE | DIEMS
4.2 History of Java

Workbook on Object Oriented Programming in Java


5
Prepared By: Ms. Priyanka B. Dhas | Dept of CSE | DIEMS
4.3 What is Java-Based Upon?

Java is based on C and C++. The first Java compiler was developed by
Sun Microsystems and was written in C using some libraries from C++.
Java files are converted to bit code format using a compiler that the Java
interpreter then executes. Java is different from c and c++ with respect to
following scenarios

Workbook on Object Oriented Programming in Java


6
Prepared By: Ms. Priyanka B. Dhas | Dept of CSE | DIEMS
4.3.1 Basic Java Terminology

Before we start learning Java, let’s get familiar with common java terms.

• Environment which supports developer to develop software using


java program

• JDK (Java Development Kit) : is a software development


environment used for developing Java applications and applets. It
includes the Java Runtime Environment (JRE), an
interpreter/loader (Java), a compiler (javac), an archiver (jar), a
documentation generator (Javadoc), and other tools needed in
Java development.

• Javac: It is java compiler which compiles .java (source code)


and gives Bytecode as an Output.

• Bytecode : is the intermediate representation of a Java program,


allowing a JVM to translate a program into machine-level
assembly instructions. When a Java program is compiled,
bytecode is generated in the form of a . class file.

• JRE (Java Runtime Environment): The Java Runtime


Environment provides the minimum requirements for executing a
Java application; it consists of the Java Virtual Machine (JVM),
core classes, and supporting files.

• JVM (Java Virtual Machine): is an abstract computing


machine. JVM executes the bytecode generated by compiler. This
is called program run phase.

• JIT (Just in Time Compiler) : In computing, just-in-time


compilation is a way of executing computer code that involves
compilation during execution of a program rather than before
execution. Most often, this consists of source code or more
commonly bytecode translation to machine code, which is then
executed directly.

Workbook on Object Oriented Programming in Java


7
Prepared By: Ms. Priyanka B. Dhas | Dept of CSE | DIEMS
• Following image depicts how all the terms are
connected with each other

4.3.2 Features of Java

Click here to read : Features of Java please go through


link

Workbook on Object Oriented Programming in Java


8
Prepared By: Ms. Priyanka B. Dhas | Dept of CSE | DIEMS
4.3.3 Program Structure
Java is a bunch of many inbuilt classes, object, libraries and
concepts. Before proceeding for it we will go through simple
java program structure. Below given image shows basic
structure:

In java main method plays important role and its structure is


somewhat different. public static void main(String[] args) is
the most important Java method.
• When you start learning java programming, this is
the first method you encounter.
• Every Java application has at least one class and at
least one main method.
• Normally, an application consists of many classes

Workbook on Object Oriented Programming in Java


9
Prepared By: Ms. Priyanka B. Dhas | Dept of CSE | DIEMS
and only one of the class needs to have a main
method.

• Following diagram shows description of main


method.

Exercise :
1. What is the purpose of the method public static void
main in a Java program?
2. What is the purpose of System.out.println()?
3. Write a program to display hello world
Solution:

Workbook on Object Oriented Programming in Java


10
Prepared By: Ms. Priyanka B. Dhas | Dept of CSE | DIEMS
Take the reference of above example and solve following
exercise
1. Write a program to display following output:
Hello, I am Ram.
Hi, I am Ramesh.
2. Write a program to display 1 to 10 Numbers.

Keywords in java:

abstract continue for new switch


synchronize
assert*** default goto* package
d
boolean do if private this
protecte
break double implements throw
d
byte else import public throws
case enum**** instanceof return transient
catch extends int short try
char final interface static void
strictfp*
class finally long *
volatile

const* float native super while

Above mention keywords are reserved in java you cannot use


these keywords as an identifier (Identifiers means name given
to variable, method, class, package, loop etc.)

Control Statements:
Every programming language has control structures which
are used to control the execution flow of the code.

Workbook on Object Oriented Programming in Java


11
Prepared By: Ms. Priyanka B. Dhas | Dept of CSE | DIEMS
Following are the control statements in java:

List of keywords which are used to write control statements:


If, else, while, for, do, break, continue, return, switch, default,
case.
In which scenarios control structures can be helpful for solving
program based technical aptitude test in placement drives.
• Pattern programs
• String program
• Solving various mathematical series (Fibonacci)
• Finding numbers in given range (prime numbers, odd,
even, factorial etc.)
• Finding marks ranges, percentage of students.
For more details click on link: control statements.
Example: Write program to display below given pattern.

Workbook on Object Oriented Programming in Java


12
Prepared By: Ms. Priyanka B. Dhas | Dept of CSE | DIEMS
Solution :

Exercise:
1. Write a program in Java to display n terms of natural
numbers and their sum.
Test Data
Input the number: 2
Expected Output:
Input number: 2
The first n natural numbers are:
2
1
2
The Sum of Natural Number up to n terms: 23
2. Solve the challenge given in following link
https://www.hackerrank.com/challenges/java-if-
else/problem
3. Write a java program to find sum of all digits of a given
number.

Workbook on Object Oriented Programming in Java


13
Prepared By: Ms. Priyanka B. Dhas | Dept of CSE | DIEMS
4.3.4 What you will learn under Core Java

• OOPS Concepts in Java


• Java Variables, Methods
• Control Structures
• Class and Object
• Constructors, Constructor Overloading
• Arrays
• Strings
• Access Modifiers
• Packages
• Inheritance and Polymorphism
• Exception Handling
1. Java Programming language is very vast in terms of
services and supports it provides for development of the
product as well as service to maintain already available
products.
2. Above mentioned topics are basic concepts which comes
under core java.

4.3.5 To study these topics please refer below given link:

Java Tutorial 1
Java Tutorial 2
Edureka Video Tutorial
Telusko Video Tutorial
Java Hindi Tutorial

Workbook on Object Oriented Programming in Java


14
Prepared By: Ms. Priyanka B. Dhas | Dept of CSE | DIEMS
Road Map to learn Java Technology:
Click for more details

Workbook on Object Oriented Programming in Java


15
Prepared By: Ms. Priyanka B. Dhas | Dept of CSE | DIEMS
Workbook on Object Oriented Programming in Java
16
Prepared By: Ms. Priyanka B. Dhas | Dept of CSE | DIEMS
Workbook on Object Oriented Programming in Java
17
Prepared By: Ms. Priyanka B. Dhas | Dept of CSE | DIEMS

You might also like