0% found this document useful (0 votes)
5 views

Lecture Slide Week-1

The document outlines a course on Object-Oriented Programming using Java, detailing course outcomes, evaluation components, and resources. It covers fundamental concepts such as Java's history, features, data types, variables, and operators, along with practical examples of Java programs. The course aims to equip students with the skills to develop applications using Java's object-oriented principles and various programming structures.

Uploaded by

Aman Singh
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)
5 views

Lecture Slide Week-1

The document outlines a course on Object-Oriented Programming using Java, detailing course outcomes, evaluation components, and resources. It covers fundamental concepts such as Java's history, features, data types, variables, and operators, along with practical examples of Java programs. The course aims to equip students with the skills to develop applications using Java's object-oriented principles and various programming structures.

Uploaded by

Aman Singh
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/ 55

OBJECT ORIENTED

PROGRAMMING
USING JAVA
Course Foundation L T P Credits
Type:
3 1 4 6

COURSE CREDITS
COURSE OUTCOME

CO1: To examine different programming structures in a platform


Examine independent language such as wrapper classes, collections, exceptions,
and multithreading.

CO2: To explain the concepts of object-oriented programming like encapsulation,


abstraction, inheritance and polymorphism. Also java specific implementation of
Explain features like collection framework and multithreading would be covered.

CO3:Make use of GUI and database based programming to develop Applications


Implement for real life problems.
Course Components Marks
Lab Continuous evaluation 20
Mid Term 20
End Term 40
Project 10
Certification 5
Quiz 5

EVALUATION COMPONENT
 Edx-Object Oriented Programming in Java.
https://www.edx.org/course/introduction-to-java-programming-
starting-to-code
 Coursera-Object Oriented Programming in Java Specialization.

RESOURCES https://www.coursera.org/specializations/object-
oriented-programming
▪ MIT OpenCourseWare-Introduction to Programming in Java.
https://ocw.mit.edu/courses/electrical-engineering-and-computer-
science/6-092-introduction-to-programming-in-java-january-iap-2010/
 Lab Platform
 CodeTantra (Continuous Labs & Exams)

 IDE
LABTOOL
 VS Code
 Eclipse
 Netbeans
 IntelliJ IDEA
FUNDAMENTALS
 Introduction to Java
 Bytecode
 JVMArchitecture
 Applications of Java
OUTLINE  Types of JavaApplication
 History of Java
 Features of Java
 Simple Java Program
 DataType
 Variable
 Variable Name
OUTLINE  Operators
 Precedence of Operators
 Examples of Operators
INTRODUCTION TO JAVA

❑ Java is a general purpose programming language.


❑ It is High Level language.
❑ Java was originally developed by James Gosling at Sun
Microsystems in 1995.
❑ Java is a language that is platform independent.
❑ A platform is the hardware and software environment in
which a programs run.
❑ Java has its own Java Runtime Environment (JRE) andAPI.
INTRODUCTION TO JAVA (CONT…)

❑ Java code is once compiled, it can run on any platform


without recompiling or any kind of modification.
❖ “Write Once RunAnywhere”
❑ The aforementioned feature of Java is supported by Java
Virtual Machine (JVM).
❖ First, Java code is complied into bytecode. This bytecode gets
interpreted on different machines. Java bytecode is the result of the
compilation of a Java program, an intermediate representation of that
program which is machine independent.
BYTECODE

❑ When we write a program in Java, at first, the compiler


compiles the program and a bytecode is generated.
❑ When we wish to run this .class file on any other platform,
we can do so.
❑ After the first compilation, the generated bytecode is now
run by the Java Virtual Machine and the processor is not in
consideration (only java installation is required).
❑ Implementation of JVM is based on stack.
S
BYTECODE (CONT…)

Fig 1: Bytecode
JVMARCHITECTURE

Fig 2: JVM architecture


APPLICATIONS OF JAVA

❑ Approx. 3 Billion devices run java. Some of them are as


follows:
❖ Desktop applications
❖ Web applications
❖ Enterprise applications (banking)
❖ Mobile
❖ Embedded system
❖ Smart card
❖ Robotics
❖ Games
TYPES OF JAVAAPPLICATION

❑ There are 4 type of java applications:


❖ Standalone Application: An application that install on each system
(AWT and Swing are used).
❖ Web Application: An application that runs on the server side and
creates dynamic page (servlet, jsp, etc are used).
❖ Enterprise Application: An application that is distributed in nature,
such as banking applications. It has the advantage of high level
security and load balancing.
❖ Mobile Application: An application that is created for mobile devices
(Android and Java ME are used).
HISTORY OF JAVA
❑ James Gosling, Mike Sheridan, and Patrick Naughton
initiated the Java language project in June 1991. The small
team of sun engineers called Green Team.
❑ Firstly, it was called "Greentalk" by James Gosling and file
extension was .gt.
❑ After that, it was called Oak and developed as a part of the
Green project.
❑ In 1995, Oak was renamed as "Java“.
❑ JDK 1.0 released in 23 Jan 1996.
FEATURES OF JAVA
❑ There are many features of Java:
❖ Object-oriented
❖ Platform independent
❖ Secure
❖ Robust
❖ Portable
❖ Dynamic
❖ High performance
❖ Multithread
❖ Distribute
SIMPLE JAVA PROGRAM
❑ To create a simple java program, you need to create a class
that contains main method.
class Hello
{
public static void main(String args[])
{
System.out.println(“Hello World”);
}
}
SIMPLE JAVA PROGRAM (CONT…)

❑ Save: Save as Hello.java

❑ To compile: javac Hello.java

❑ To execute: java Hello

❑ Output: Hello World


SIMPLE JAVA PROGRAM (CONT…)
❑ class keyword is used to declare a class.
❑ public keyword is an access modifier, which represents visibility. It means it is
visible to all.
❑ static is a keyword. If we declare any method as static, it is known as the static
method. The core advantage of the static method is that there is no need to
create an object to invoke the static method. The main method is executed by
the JVM, so it doesn't require to create an object to invoke the main method.
Thus, it saves memory.
❑ void is the return type of the method. It means it doesn't return any value.
❑ main represents the starting point of the program.
❑ String args [] is an array of strings which stores arguments passed by command
line while starting a program.
❑ System.out.println() is used to print statement. Here, System is a class, out is
the object of PrintStream class, println() is the method of PrintStream class. 14
SIMPLE JAVA PROGRAM (CONT…)

❑ The subscript notation in Java array can be used after type, before the variable or after the variable.

❖ public static void main(String[] args)

❖ public static void main(String []args)

❖ public static void main(String args[])


SIMPLE JAVA PROGRAM (CONT…)
❑ Valid Java main method signature:
❖ public static void main(String[] args)

❖ public static void main(String []args)

❖ public static void main(String args[])

❖ public static void main(String... args)

❖ static public void main(String[] args)


SIMPLE JAVA PROGRAM (CONT…)
❑ Invalid Java main method signature:

❖ public void main(String[] args)

❖ static void main(String[] args)

❖ public void static main(String[] args)


SIMPLE JAVA PROGRAM (CONT…)
❑ Giving a semicolon at the end of a class is optional in Java.

class Hello
{
public static void main(String args[])
{
System.out.println(“Hello World”);
}
};
DATATYPE

❑ There are mainly two types of data type:


❖ Primitive: Byte, short, int, long, float, double, boolean
and char.

❖ Non-primitive: String, arrays and classes


DATA TYPE (CONT.)
VARIABLE

❑ A variables can be considered as a name given to the


location in memory where values are stored.\
❖ <datatype> <variable_name>
❑ Can the value of variable be changed?
❖ Yes
VARIABLE NAME

❑Use only the characters ‘a’through ‘z’, ‘A’through ‘Z, ‘0’ through ‘9’, character ‘_’, and character ‘$’.
❑ A name can’t contain space character.
❑ Do not start with a digit. Variable name can be of any length.
❑ Case sensitive.
❑ A name can not be a reserved word (A reserved word is a
word which has a predefined meaning in Java. Example: int, double, true, etc.).
VARIABLE NAME (CONT…)

❑Can you answer that whether the below lines are correct or
not?
1. int good-bye;
2. int shrift = 0;
3. char thisMustBeTooLong;
4. int bubble = 0, toil = 9, trouble = 8
5. int 8ball;
6. int double;
VARIABLE NAME (CONT…)

❑ Answers of the last slide:


1. int good-bye; //bad variable name
2. int shrift = 0; //OK
3. char thisMustBeTooLong; //OK in syntax //but poor choice
in variable name
4. int bubble = 0, toil = 9, trouble = 8 // “;” missing at the end
5. int 8ball; //can’t start with a digit
6. int double; //double is a reserve word
OPERATORS

❑ There are many operators in Java::


❖ Unary operators
❖ Arithmetic operators
❖ Relational operators
❖ Bitwise operators
❖ Logical operators
❖ Assignment operators
❖ Ternary operators
OPERATORS (CONT.…)

❑ Unary operators:
OPERATORS (CONT.…)

❑ Arithmetic operators:
OPERATORS (CONT.…)

❑ Relational operators:
OPERATORS (CONT.…)

❑ Bitwise operators:
OPERATORS (CONT.…)

❑ Logical operators:
OPERATORS (CONT.…)

❑ Assignment operators:
OPERATORS (CONT.…)

❑ Ternary operators:

❖ Conditional Operator ( ? : )
PRECEDENCE OF THE OPERATORS
EXAMPLES OF OPERATORS
EXAMPLES OF OPERATORS

Output:
❖ 10
❖ 12
❖ 12
❖ 10
EXAMPLES OF OPERATORS (CONT.…)
EXAMPLES OF OPERATORS (CONT.…)

Output:
❖ 21
EXAMPLES OF OPERATORS
(CONT.…)
EXAMPLES OF OPERATORS
(CONT.…)

Output:
❖ 40
❖5
EXAMPLES OF OPERATORS
(CONT.…)
EXAMPLES OF OPERATORS
(CONT.…)

Output:
❖ false
❖ false
EXAMPLES OF OPERATORS
(CONT.…)
EXAMPLES OF OPERATORS
(CONT.…)

Output:
❖3
EXAMPLES OF OPERATORS
(CONT.…)
EXAMPLES OF OPERATORS
(CONT.…)

Output:
❖ 16
❖ 13
❖ 52
❖ 10
EXAMPLES OF OPERATORS
(CONT.…)
EXAMPLES OF OPERATORS
(CONT.…)

Output:
❖ a == b = false
❖ a != b =true
❖ a > b =false
❖ a < b =true
❖ a >= b =false
❖ a <= b =true
THANK YOU

You might also like