Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Object-Oriented Programming through Java, Study notes of Object Oriented Programming

A compilation of 11 lectures from introducing to advanced level of OOP through Java

Typology: Study notes

2020/2021

Uploaded on 05/31/2021

shailen_555cell
shailen_555cell 🇺🇸

4.7

(19)

264 documents

1 / 308

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
OOP - JAVA
Object-Oriented Programming
Java
Margit ANTAL
2021
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Object-Oriented Programming through Java and more Study notes Object Oriented Programming in PDF only on Docsity!

OOP - JAVA

Object-Oriented Programming

Java

Margit ANTAL

Goals

  1. Java Language
  2. Objects and classes
  3. Static Members
  4. Relationships between classes
  5. Inheritance and Polymorphism
  6. Interfaces and Abstract Classes
  7. Exceptions
  8. Nested Classes
  9. Threads
  10. GUI Programming
  11. Collections and Generics

Java language

● History

● Java technology: JDK, JRE, JVM

● Properties

● 'Hello world' application

● Garbage Collection

Short History

● 1991 - Green Project for consumer electronics market

(Oak language → Java)

● 1994 – HotJava Web browser

● 1995 – Sun announces Java

● 1996 – JDK 1.

● 1997 – JDK 1.1 RMI, AWT, Servlets

● 1998 – Java 1.2 Reflection, Swing, Collections

● 2004 – J2SE 1.5 (Java 5) Generics, enums

● 2014 – Java SE 8 Lambdas

Java technology

● JDK – Java Development Kit

● JRE – Java Runtime Environment

● JVM – Java Virtual Machine

JDK javac, jar, debugging

JRE java, libraries

JVM

Properties

● Object-oriented

● Interpreted

● Portable

● Secure and robust

● Scalable

● Multi-threaded

● Dynamic language

● Distributed

Hello World Application

HelloWorld.java

HelloWorld.class

javac HelloWorld.java

bytecode

java HelloWorld

Runtime

JVM

Garbage Collection

● Dynamically allocated memory

● Deallocation

− Programmer's responsibility (C/C++)

− System responsibility (Java):

● Is done automatically (system-level thread)

● Checks for and frees memory no longer needed

Module 2

Object-Oriented Programming

Object-oriented programming

Classes and Objects

● Class

● Attributes and methods

● Object (instance)

● Information hiding

● Encapsulation

● Constructors

● Packages

Declaring Classes

● Syntax

* class <class_name>{

<attribute_declaration>*

<constructor_declaration>*

<method_declaration>*

● Example

public class Counter{ private int value; public void inc(){ ++value; } public int getValue(){ return value; } }

Declaring Attributes

● Syntax

* <attribute_name>[= <initial_value>];

● Examples

public class Foo{ private int x; private float f = 0.0; private String name =”Anonymous”; }

Accessing Object Members

● Syntax

.

● Examples

public class Counter{ public static final int MAX = 100; private int value = 0;

public void inc(){ if( value < MAX ){ ++value; } } public int getValue(){ return value; } }

Counter c = new Counter(); c.inc(); int i = c.getValue();

Information Hiding

● The problem:

● Client code has direct access to internal data

/* C language */

struct Date {

int year, month, day;

/* C language */

Date d;

d.day = 32; //invalid day

d.month = 2; d.day = 30;

// invalid data

d.day = d.day + 1;

// no check