SlideShare a Scribd company logo
Object Orientated Programming with Java Jussi Pohjolainen Tampere University of Applied Sciences
MOTIVATION
Job Opportunities? Little acronyms from job descriptions: S60, C++, J2ME, Java, Java EE, SCRUM, JAX-WS 2.0, EJB 3.0, Spring, Hybernate, Struts, SQL, XHTML, CSS, Symbian C++, Perl, PHP, Python, LDAP, MFC, XML, .NET, Visual Basic, AJAX, Objective-C, JSP, Servlet, GTK, Qt, JavaScript, Oracle, SQL Server, DB Design… Where is Object Orientated programming?
Developing S60 apps? “ Basic” programming skills OO skills Data Structures / DB UI programming Symbian C++ S60
Developing iPhone apps? “ Basic” programming skills OO skills Data Structures / DB UI programming Objective-C iPhone
Web-development with Java? “ Basic” programming skills OO skills Data Structures /DB UI programming Java Servlet Www-techniques: Xhtml, CSS, XML Applets JSP
OO CONCEPTS
Intro to OO Object Orientated programming is a  programming paradigm. One way of describing the structure of the application Several paradigms available.  Procedural, Functional, ... OO is nowdays one of the most popular. C++ Java C# PHP 5 ...
Benefits Reusability Once you written code, you can reuse it! Management Application is programmed using classes and objects. Pieces that communicate with each other. Maintanence When changing the code, it does not influence the whole application.
Basic Concept:  Object In real life, the world consists of  objects: cars, buildings, trees, ships, humans, flowers.. Every object has actions (=methods!) that can incluence other objects jack drives ferrari.  Object  jack  has a method  drive  that influences some way to object  ferrari. jack.drive(ferrari); In OO, you should implement the app so that it consists of objects that influence each other!
Example about an Object Datsun 100A is an  object Datsun 100A has different actions or  methods : drive, brake, park... Datsun 100A has information or  attributes : color, amount of gears, amount of doors...
Basic Concept: Class Class is a blueprint or template of an object Class describes the state and behaviour to it's objects. Object is created from the class.
Example about an Class If Datsun 100A is an object, Car is a class. If one wants to create Datsun 100A, you have to have first the blueprints of the Datsun.  Blueprints of an object: Class Class Car -> Object Datsun 100A
Examples: Class to Object Class Object Car datsun 100a Human Jack Bauer Color red Laptop MacBook Pro String "some string" Array {1,2,3,2,4} ... ...
Class and Object Car - class Datsun 100A Lamborghini Diablo Peugeot 406
Car's Blueprint When building a Car's blueprint (class), you have to think that what is similar in all car's So what is similar in datsun, lamborghini and peugeot?
Objects datsun, lambo, peugeot datsun: brand: Datsun 100A , motor: 1.0, fuzzy dices: yes, color: red lambo brand: Lamborghini Diablo, motor: 8.0, fuzzy dices: no, color: punainen peugeot brand: Peugeot 406, motor: 2.2, fuzzy dices: no, color: blue
Car's Blueprint (Class) in UML Car brand motor amountOfDoors color hasFuzzyDices . .
From Class to Object datsun Datsun 100A 1.0 3 red true lambo Lamborghini Diablo 8.0 3 red false Car brand motor amountOfDoors color hasFuzzyDices . .
Car-class, extension Car brand motor amountOfDoors color hasFuzzyDices drive park brake
Class Class is a template or blueprint to object Class holds Attributes (=variables) Actions (=methods) Class instances are called objects
CLASSES AND OBJECTS IN JAVA
Person Class to Objects george George Smith 40 Teacher 09-12345 Jack Jack Puupää 60 Toimistopäällikkö 03-654321 eat sleep drinkBeer Person firstname lastname age profession phonenumber eat sleep drinkBeer
Person – class to Java class Person { public String firstname;    public String lastname;   public int age;   public String profession;   public int phonenumber;   public void eat() { System.out.println("Eating!"); }   public void sleep() { System.out.println("Sleeping!"); } public void drinkBeer() { System.out.println("Drinking!"); } } Person firstname lastname age profession phonenumber eat sleep drinkBeer
From Class to Object App always starts from the main-method Let's test the Person – class This creates a variable a which type is integer int a; This creates a object jack which type is Person Person jack;
From Class to Object class Person { .... } class JustTesting { public static void main(String [] args)  { // Declare the object Person jack; // Initialize the object jack = new Person(); jack.firstname = "Jack"; jack.lastname  = "Smith"; jack.drinkBeer(); } }
Example: Car - class class Car { public String brand; public int amountOfGas;  public void drive() { amountOfGas--; } }
Creating Objects From the Class class Car { .... } class JustTesting { public static void main(String [] args)  { Car datsun = new Car(); datsun.amountOfGas = 100; datsun.drive(); System.out.println(datsun.amountOfGas); Car ferrari = new Car(); ferrari.amountOfGas = 300; ferrari.drive(); System.out.println(ferrari.amountOfGas); } }
Basic Concept - Encapsulation private public method
About Attributes Attributes are usually marked as private The reason for this is that other objects cannot change the values as they will You don't for example want that every object in the world can change person's weight to 500kg...
Example: Person - class class Person { private  String name; private  int weight; }
class Person { private  String name; private  int weight; } class JustTesting { public static void main(String [] args)  { Person jack = new Person(); jack.name = "Jack Smith"; jack.weight = 500; } } RESULT: TB308POHJUS-L-2:temp pohjus$ javac Person.java  Person.java:9: name has private access in Person jack.name = "Jack Smith"; ^ Person.java:10: weight has private access in Person jack.weight = 500; ^ 2 errors
class Person { private  String name; private  int weight; public void setName(String n) { name = n; } public String getName() { return name; } public void setWeight(int w) { if(w > 0 && w <= 150)  weight = w;  } public int getWeight() { return weight; } } class JustTesting { public static void main(String [] args)  { Person jack = new Person(); jack.setName(&quot;Jack Smith&quot;); jack.setWeight(200); System.out.println(jack.getName()); } }
Accessor and Mutator - methods class Person { private String name; private int weight; // Mutator public void setName(String n) { name = n; } // Accessor  public String getName() { return name; } // Mutator  public void setWeight(int w) { if(w > 0 && w <= 150)  weight = w;  } // Accessor public int getWeight() { return weight; } }
JAVA TYPES
Java Types Java has two type of types 1) Primitive types byte, short, int, long, double, float, char, boolean 2) Class types String, Scanner, Array, JButton, JFrame ...
Differences Primitive types are spelled with lowercase: int, double, float... Class types are spelled with uppercase String, Scanner, Person, Cat, Car ... Primitive type declaring and initialization int a = 5; Class type declaring and initialization with  new Dog spot = new Dog();
Differences Primitive type int a = 5; Class type int [] b= new int[5]; b holds memory address a holds value 5.
Memory Address? int [] b = new int[2]; b[0] = 1; b[1] = 2; // prints 0x01 System.out.println(b); RAM variable b address value 0x01 1 0x02 2 address value 0x09 0x01
Memory Address? int [] b = new int[2]; b[0] = 1; b[1] = 2; int [] a = b; // prints 0x01 System.out.println(b); // prints 0x01 System.out.println(a); RAM variable b variable a address value 0x01 1 0x02 2 address value 0x09 0x01 address value 0x19 0x01
Output? int [] b = new int[2]; b[0] = 1; b[1] = 2; int [] a = b; b[0] = 99; // Output? System.out.println(a[0]);
Differences Again Primitive type int a = 5; Class type int [] b= new int[5]; b holds  memory address a holds  value 5.
Differences Again Primitive type int a = 5; Class type Person jack = new Person() jack holds  memory address a holds  value 5.
Output? Person jack = new Person(); jack.setName(&quot;Jack Smith&quot;); Person james = jack; james.setName(&quot;James Bond&quot;); // output? System.out.println(jack.getName());
Methods and Variables public void method(int x) { x++; } public void main(String [] args) { int y = 3; method(y); // Output is 3! System.out.println(y); }
Methods and Variables public void method(int [] x) { x[0] = 12; } public void main(String [] args) { int [] y = {1,2,3}; method(y); // Output is 12 since array is class type! System.out.println(y[0]); }
String String is an exception to the rules String is a class type that acts like primitive type String is the only class type that can be initialized without the  new  word. String a = &quot;hello&quot;; String is passed by value in methods, so String is  copied  when moving strings in methods.
String and Memory String variables are objects => holds memory address. Comparing contents a.equals(b); Comparing memory addresses a == b
CONSTRUCTOR
Constructors Constructor is a “init method” that is called when an object is created Java provides default constructor (= constructor with no parameters) Constructor has the same name than the class Constructor does not return anything Constructor usually initalizes class members
Example class Car { public Car() { System.out.println(&quot;Constructor!&quot;); } } class Test { public static void main(String [] args) { Car datsun = new  Car(); } } > java Test Constructor!
class Car { private String brand; public Car(String b) { brand = b; } public String getBrand() { return brand; } } class Test { public static void main(String [] args) { Car datsun = new  Car(&quot;Datsun 100A&quot;); System.out.println( datsun.getBrand() ); } } > java Test Datsun 100A
Multiple Constructors class Car { public Car() { // Do something  } public Car(String brand) { // Do something else } } class Test { public static void main(String [] args) { Car datsun  = new  Car(); Car ferrari = new  Car(&quot;Ferrari&quot;); } }
Problem? class Car { String brand; public Car(String brand) { brand = brand; } } class Test { public static void main(String [] args) { Car datsun = new Car(&quot;Datsun 100a&quot;); } } > java Test null
Solution class Car { String brand; public Car(String brand) { this.brand = brand; } } class Test { public static void main(String [] args) { Car datsun = new Car(&quot;Datsun 100a&quot;); } } > java Test Datsun 100a
COMPOSITION
Composition Relatioship between objects, where one object owns, or  has  the other object Car  has or owns  Motor When Car is build, it's motor is built also When Car is destroyed it's motor is destroyed
UML notation
Java: Composition // Composition class Car { private Motor motor; public Car() { motor = new Motor(); } }
One to Many?
Java: One to Many class Department { private Professor [] members; private int numberOfMembers; public Department(Professor prof) { members = new Professor[20];  members[0] = prof; numberOfMembers = 1; } public void addProfessor(Professor prof) { members[numberOfMembers] = prof; numberOfMembers++; } }
INHERITANCE
Introduction to Inheritance Inheritance is a relationship between two or more classes where derived class inherites behaviour and attributes of pre-existing (base) classes Intended to help  reuse  of existing code with little or no modification
Inheritance Inheritance can be continous Derived class can inherit another class, which inherits another class and so on When changing the base class all the derived classes changes also Example:  Mammal <– Human <– Worker <- Programmer Could mammal be a derived class? If so, what would be the base class?
Picture about Inheritance C lass B F eatures: a,b,c C lass D F eatures: a,b,d,e,f a b C lass A features: a,b c d e C lass C F eatures: a,b,d,e f
Multiple Inheritance In multiple inheritance a derived class has multiple base classes C++ supports multiple base classes, Java don't Driver - license -  Y ear of approval Conductor -  A ccount number Taxi Driver - area House Boat Houseboat
Inheritance and Capsulation private Is  accessible  only via the base class public Is accessible everywhere (base class, derived class, othe classes) protected Is accessible by the base class and derived classes
Basic example What are Programmer's attributes and methods?  Human string name void sleep() void drink() void eat() Programmer int salary void implementApps() void beNerd()
Overriding? What about now? Human string name void sleep() void drink() void eat() Programmer int salary void implementApps() void beNerd() void drink() void eat()
Overriding Since programmer eats and drinks differently than humans (only Coke and Pizza) the eat and drink methods are overriden in Programmer!
Abstract Class Abstract class is a class which you cannot instantiate (create objects) You can inherit abstract class and create objects from the inherited class, if it is concrete one Abstract class in C++ has abstract methods, that do not have implementations These methods forces derived classes to implement those methods
Example <<abstract>> Mammal string name void makesound() {abstract} Elephant int trunkLength makesound()
Example <<abstract>> Figure int x, y double calculateArea() {abstract} Circle double radius double calculateArea() Rect double length, height double calculateArea()
INHERITANCE IN JAVA
Example: Basic Inheritance class Human { public void sleep() { System.out.println(&quot;Human sleeps&quot;); } } class Programmer  extends Human  { } class Test { public static void main(String [] args) { Programmer jussi = new Programmer(); jussi.sleep(); // &quot;Human sleeps&quot;  } }
Example: Overriding class Human { public void sleep() { System.out.println(&quot;Human sleeps&quot;); } } class Programmer  extends Human  { public void sleep() { System.out.println(&quot;Programmer sleeps&quot;); } } class Test { public static void main(String [] args) { Programmer jussi = new Programmer(); jussi.sleep(); // &quot;Programmer sleeps&quot;  } }
Example: super class Human { public void sleep() { System.out.println(&quot;Human sleeps&quot;); } } class Programmer extends Human  { public void sleep() { super.sleep(); System.out.println(&quot;Programmer sleeps&quot;); } } class Test { public static void main(String [] args) { Programmer jussi = new Programmer(); jussi.sleep();  } } > java Test Human sleeps Programmer sleeps
Constructors and Inheritance class Human { public Human() { System.out.println(&quot;Human&quot;); } } class Programmer extends Human  { public Programmer() { System.out.println(&quot;Programmer&quot;); } } class Test { public static void main(String [] args) { Programmer jussi = new Programmer(); } } > java Test Human Programmer
Constructors and Inheritance Constructor allways calls the base classes constructor! When creating a constructor void Human() { } Java adds super() – call to it: void Human() { super(); // calls base classes constructor }
class Human { public Human() { System.out.println(&quot;Human&quot;); } } class Programmer extends Human  { public Programmer() { System.out.println(&quot;Programmer&quot;); } } class Test { public static void main(String [] args) { Programmer jussi = new Programmer(); } } > java Test Human Programmer
class Human { public Human() { super(); // Java adds this! Calls base classes contructor System.out.println(&quot;Human&quot;); } } class Programmer extends Human  { public Programmer() { super(); // Java adds this! Calls base classes contructor System.out.println(&quot;Programmer&quot;); } } class Test { public static void main(String [] args) { Programmer jussi = new Programmer(); } } > java Test Human Programmer
What the...? What base class? class Human { public Human() { // Java adds this! Calls base classes contructor super();  System.out.println(&quot;Human&quot;); } }
Object Every class derives from a class called Object. // Java adds the  extends Object  too! class Human  extends Object  { public Human() { super();  System.out.println(&quot;Human&quot;); } }
Object clone() equals() finalize() toString() ... Human String name ... http://java.sun.com/javase/6/docs/api/java/lang/Object.html
class Human { public Human( int a ) { System.out.println(&quot;Human&quot;); } } class Programmer extends Human  { public Programmer() { System.out.println(&quot;Programmer&quot;); } } class Test { public static void main(String [] args) { Programmer jussi = new Programmer(); } } > javac Test.java > DOES NOT COMPILE!!! Why?
class Human { public Human( int a ) { System.out.println(&quot;Human&quot;); } } class Programmer extends Human  { public Programmer() { super(); // Java adds this and it calls constructor // Human() that does not exist.. System.out.println(&quot;Programmer&quot;); } } class Test { public static void main(String [] args) { Programmer jussi = new Programmer(); } }
class Human { public Human( int a ) { System.out.println(&quot;Human&quot;); } } class Programmer extends Human  { public Programmer() { super(5); // Now it works: Human(int a) exists. System.out.println(&quot;Programmer&quot;); } } class Test { public static void main(String [] args) { Programmer jussi = new Programmer(); } }
class Human { private String name public Human( String name ) { this.name = name; } } class Programmer extends Human  { private int salary; public Programmer(String name, int salary) { super(name); this.salary = salary; } } class Test { public static void main(String [] args) { Programmer jussi = new Programmer(&quot;Jussi&quot;, 5000); } }
Abstract Class From abstract class  you cannot create objects! Abstract class is usually used with inheritance Abstract class  may contain abstract methods. Abstract method forces derived classes to implement the abstract method.
Abstract Class: example abstract  class Mammal { abstract void makeSound(); } class Dog extends Mammal { // You have to implement this! public void makeSound() { System.out.println(&quot;Bark!&quot;); } }
Abstract Class: example // Does NOT work, since Mammal is  // abstract class Mammal object = new Mammal(); // Does work Dog spot = new Dog();
Java: Abstract class and Interface Abstract class can hold &quot;normal&quot; methods and abstract methods. Interface holds only abstract methods Abstract class: class A  extends  someAbstractClass Interface class A  implements  someInterface
Abstract class to Interface abstract  class Movable { abstract public void start(); abstract public void stop(); }  interface Movable { public void start(); public void stop(); }
Implementing the Interface interface Movable { public void start(); public void stop(); } class Car  implements Movable { // You have to implement these public void start() { // Do something }  public void stop() { // Do something }  }
Abstract class vs Interface Abstract class can hold normal methods and abstract methods Interface can hold only abstract methods Class can inherite only one base class Class can implement several interfaces!
class Car  extends Vehicle implements Movable, RunsOnGasoline { // You have to implement these public void start() { // Do something }  public void stop() { // Do something }  public void reduceGasoline() { // Do something } public void addGasoline() { // Do something    } }
POLYMORPHISM
int as parameter class Exercise13 { public static void main(String [] args) { int x = 4; myMethod(x);   } public static void myMethod(int a) { } }
Human parameter class Human { } class Exercise13 { public static void main(String [] args) { Human jack = new Human(); myMethod(jack);   } public static void myMethod(Human a) { } }
Mammal parameter class Mammal { } class Human extends Mammal { } class Dog extends Mammal { } class Exercise13 { public static void main(String [] args) { Human jack = new Human(); Dog spot = new Dog(); Mammal mammal = new Mammal(); // these work! You can pass mammals, dogs and humans to the method! myMethod(jack); myMethod(dog); myMethod(mammal);  } public static void myMethod(Mammal a) { } }
Object parameter ... class Exercise13 { public static void main(String [] args) { Human jack = new Human(); Dog spot = new Dog(); Mammal mammal = new Mammal(); // these work! You can pass every object to the method myMethod(jack); myMethod(dog); myMethod(mammal);  myMethod(&quot;hello&quot;); // String } public static void myMethod(Object a) { } }
Calling methods from Mammal class Mammal { } class Human extends Mammal { public void bark() { System.out.println(&quot;Bark!&quot;); }; } class Dog extends Mammal { } class Exercise13 { public static void main(String [] args) { Human jack = new Human(); Dog spot = new Dog(); Mammal mammal = new Mammal(); myMethod(jack); myMethod(dog); myMethod(mammal);  } public static void myMethod(Mammal a) { a.bark(); // Why this does not work?  } }
Solution class Exercise13 { public static void main(String [] args) { Human jack = new Human(); Dog spot = new Dog(); Mammal mammal = new Mammal(); myMethod(jack); myMethod(dog); myMethod(mammal);  } public static void myMethod(Mammal a) { // Now it works if(a instanceof Dog) { Dog spot = (Dog) a; spot.bark(); }  } }
This works, why? class Mammal { public void giveBirth() { System.out.println(&quot;Giving birth&quot;); }; } class Human extends Mammal { } class Dog extends Mammal { } class Exercise13 { public static void main(String [] args) { Human jack = new Human(); Dog spot = new Dog(); Mammal mammal = new Mammal(); myMethod(jack); myMethod(dog); myMethod(mammal);  } public static void myMethod(Mammal a) { a.giveBirth(); // Why this works?  } }
class Movable { public void start(); public void stop(); } class Vehicle { } class Car extends Vehicle implements Movable { public void start() { // Do something    } public void stop() { // Do something    } } class Exercise13 { public static void main(String [] args) { Car c = new Car(); myMethod(c); } // You can pass every object that implements the Movable! public static void myMethod( Movable a ) { a.start();  } }

More Related Content

What's hot (20)

C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
Dr.Neeraj Kumar Pandey
 
Spring Boot
Spring BootSpring Boot
Spring Boot
HongSeong Jeon
 
JPA and Hibernate
JPA and HibernateJPA and Hibernate
JPA and Hibernate
elliando dias
 
Collections - Maps
Collections - Maps Collections - Maps
Collections - Maps
Hitesh-Java
 
Object Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaionObject Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaion
Pritom Chaki
 
Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)
Nuzhat Memon
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
Professional Guru
 
An Introduction to Python Concurrency
An Introduction to Python ConcurrencyAn Introduction to Python Concurrency
An Introduction to Python Concurrency
David Beazley (Dabeaz LLC)
 
Applets
AppletsApplets
Applets
Prabhakaran V M
 
Java PPT
Java PPTJava PPT
Java PPT
Dilip Kr. Jangir
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
Arzath Areeff
 
Java Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and StreamsJava Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and Streams
Anton Keks
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
Santosh Kumar Kar
 
Fundamentals of JAVA
Fundamentals of JAVAFundamentals of JAVA
Fundamentals of JAVA
KUNAL GADHIA
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
mahir jain
 
JAVA OOP
JAVA OOPJAVA OOP
JAVA OOP
Sunil OS
 
Session12 J2ME Generic Connection Framework
Session12 J2ME Generic Connection FrameworkSession12 J2ME Generic Connection Framework
Session12 J2ME Generic Connection Framework
muthusvm
 
Collections and generics
Collections and genericsCollections and generics
Collections and generics
Muthukumaran Subramanian
 
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
pcnmtutorials
 
Java Collection framework
Java Collection frameworkJava Collection framework
Java Collection framework
ankitgarg_er
 
Collections - Maps
Collections - Maps Collections - Maps
Collections - Maps
Hitesh-Java
 
Object Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaionObject Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaion
Pritom Chaki
 
Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)
Nuzhat Memon
 
Java Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and StreamsJava Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and Streams
Anton Keks
 
Fundamentals of JAVA
Fundamentals of JAVAFundamentals of JAVA
Fundamentals of JAVA
KUNAL GADHIA
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
mahir jain
 
Session12 J2ME Generic Connection Framework
Session12 J2ME Generic Connection FrameworkSession12 J2ME Generic Connection Framework
Session12 J2ME Generic Connection Framework
muthusvm
 
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
pcnmtutorials
 
Java Collection framework
Java Collection frameworkJava Collection framework
Java Collection framework
ankitgarg_er
 

Viewers also liked (15)

Connected Car Technology
Connected Car TechnologyConnected Car Technology
Connected Car Technology
Pro Car Mechanics
 
Java Basics for selenium
Java Basics for seleniumJava Basics for selenium
Java Basics for selenium
apoorvams
 
The Connected Car: Driving Towards the Future
The Connected Car: Driving Towards the FutureThe Connected Car: Driving Towards the Future
The Connected Car: Driving Towards the Future
Nudge Software Inc.
 
Realtime selenium interview questions
Realtime selenium interview questionsRealtime selenium interview questions
Realtime selenium interview questions
Kuldeep Pawar
 
Infosys Connected Vehicle Service Offerings
Infosys Connected Vehicle Service OfferingsInfosys Connected Vehicle Service Offerings
Infosys Connected Vehicle Service Offerings
Infosys
 
Chapter 1 introduction to java technology
Chapter 1 introduction to java technologyChapter 1 introduction to java technology
Chapter 1 introduction to java technology
sshhzap
 
Introduction to java technology
Introduction to java technologyIntroduction to java technology
Introduction to java technology
Indika Munaweera Kankanamge
 
Intuit commissions manager
Intuit commissions managerIntuit commissions manager
Intuit commissions manager
sshhzap
 
Chapter 1. java programming language overview
Chapter 1. java programming language overviewChapter 1. java programming language overview
Chapter 1. java programming language overview
Jong Soon Bok
 
Jena – A Semantic Web Framework for Java
Jena – A Semantic Web Framework for JavaJena – A Semantic Web Framework for Java
Jena – A Semantic Web Framework for Java
Aleksander Pohl
 
Java Basics
Java BasicsJava Basics
Java Basics
Dhanunjai Bandlamudi
 
Java session01
Java session01Java session01
Java session01
Niit Care
 
02 basic java programming and operators
02 basic java programming and operators02 basic java programming and operators
02 basic java programming and operators
Danairat Thanabodithammachari
 
Object-Oriented Analysis And Design With Applications Grady Booch
Object-Oriented Analysis And Design With Applications Grady BoochObject-Oriented Analysis And Design With Applications Grady Booch
Object-Oriented Analysis And Design With Applications Grady Booch
Sorina Chirilă
 
Connected Cars
Connected CarsConnected Cars
Connected Cars
Tata Consultancy Services
 
Java Basics for selenium
Java Basics for seleniumJava Basics for selenium
Java Basics for selenium
apoorvams
 
The Connected Car: Driving Towards the Future
The Connected Car: Driving Towards the FutureThe Connected Car: Driving Towards the Future
The Connected Car: Driving Towards the Future
Nudge Software Inc.
 
Realtime selenium interview questions
Realtime selenium interview questionsRealtime selenium interview questions
Realtime selenium interview questions
Kuldeep Pawar
 
Infosys Connected Vehicle Service Offerings
Infosys Connected Vehicle Service OfferingsInfosys Connected Vehicle Service Offerings
Infosys Connected Vehicle Service Offerings
Infosys
 
Chapter 1 introduction to java technology
Chapter 1 introduction to java technologyChapter 1 introduction to java technology
Chapter 1 introduction to java technology
sshhzap
 
Intuit commissions manager
Intuit commissions managerIntuit commissions manager
Intuit commissions manager
sshhzap
 
Chapter 1. java programming language overview
Chapter 1. java programming language overviewChapter 1. java programming language overview
Chapter 1. java programming language overview
Jong Soon Bok
 
Jena – A Semantic Web Framework for Java
Jena – A Semantic Web Framework for JavaJena – A Semantic Web Framework for Java
Jena – A Semantic Web Framework for Java
Aleksander Pohl
 
Java session01
Java session01Java session01
Java session01
Niit Care
 
Object-Oriented Analysis And Design With Applications Grady Booch
Object-Oriented Analysis And Design With Applications Grady BoochObject-Oriented Analysis And Design With Applications Grady Booch
Object-Oriented Analysis And Design With Applications Grady Booch
Sorina Chirilă
 
Ad

Similar to Object Oriented Programming with Java (20)

Oop2010 Scala Presentation Stal
Oop2010 Scala Presentation StalOop2010 Scala Presentation Stal
Oop2010 Scala Presentation Stal
Michael Stal
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
Subramanyan Murali
 
OOP with Java - continued
OOP with Java - continuedOOP with Java - continued
OOP with Java - continued
RatnaJava
 
Session 08 - OOP with Java - continued
Session 08 - OOP with Java - continuedSession 08 - OOP with Java - continued
Session 08 - OOP with Java - continued
PawanMM
 
Object Orientation vs. Functional Programming in Python
Object Orientation vs. Functional Programming in PythonObject Orientation vs. Functional Programming in Python
Object Orientation vs. Functional Programming in Python
Python Ireland
 
OOP Lab Report.docx
OOP Lab Report.docxOOP Lab Report.docx
OOP Lab Report.docx
ArafatSahinAfridi
 
Chapter 4 - Defining Your Own Classes - Part I
Chapter 4 - Defining Your Own Classes - Part IChapter 4 - Defining Your Own Classes - Part I
Chapter 4 - Defining Your Own Classes - Part I
Eduardo Bergavera
 
Java căn bản - Chapter4
Java căn bản - Chapter4Java căn bản - Chapter4
Java căn bản - Chapter4
Vince Vo
 
14. Defining Classes
14. Defining Classes14. Defining Classes
14. Defining Classes
Intro C# Book
 
Scala introduction
Scala introductionScala introduction
Scala introduction
Alf Kristian Støyle
 
Defining classes-and-objects-1.0
Defining classes-and-objects-1.0Defining classes-and-objects-1.0
Defining classes-and-objects-1.0
BG Java EE Course
 
05 Object Oriented Concept Presentation.pptx
05 Object Oriented Concept Presentation.pptx05 Object Oriented Concept Presentation.pptx
05 Object Oriented Concept Presentation.pptx
ToranSahu18
 
Esoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basicsEsoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basics
Rasan Samarasinghe
 
OOPS JavaScript Interview Questions PDF By ScholarHat
OOPS JavaScript Interview Questions PDF By ScholarHatOOPS JavaScript Interview Questions PDF By ScholarHat
OOPS JavaScript Interview Questions PDF By ScholarHat
Scholarhat
 
14. Java defining classes
14. Java defining classes14. Java defining classes
14. Java defining classes
Intro C# Book
 
Constructor&method
Constructor&methodConstructor&method
Constructor&method
Jani Harsh
 
Oop
OopOop
Oop
dilshod1988
 
Modeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based GamesModeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based Games
Ray Toal
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
MuhammadTalha436
 
Programming with Java: the Basics
Programming with Java: the BasicsProgramming with Java: the Basics
Programming with Java: the Basics
Jussi Pohjolainen
 
Oop2010 Scala Presentation Stal
Oop2010 Scala Presentation StalOop2010 Scala Presentation Stal
Oop2010 Scala Presentation Stal
Michael Stal
 
OOP with Java - continued
OOP with Java - continuedOOP with Java - continued
OOP with Java - continued
RatnaJava
 
Session 08 - OOP with Java - continued
Session 08 - OOP with Java - continuedSession 08 - OOP with Java - continued
Session 08 - OOP with Java - continued
PawanMM
 
Object Orientation vs. Functional Programming in Python
Object Orientation vs. Functional Programming in PythonObject Orientation vs. Functional Programming in Python
Object Orientation vs. Functional Programming in Python
Python Ireland
 
Chapter 4 - Defining Your Own Classes - Part I
Chapter 4 - Defining Your Own Classes - Part IChapter 4 - Defining Your Own Classes - Part I
Chapter 4 - Defining Your Own Classes - Part I
Eduardo Bergavera
 
Java căn bản - Chapter4
Java căn bản - Chapter4Java căn bản - Chapter4
Java căn bản - Chapter4
Vince Vo
 
14. Defining Classes
14. Defining Classes14. Defining Classes
14. Defining Classes
Intro C# Book
 
Defining classes-and-objects-1.0
Defining classes-and-objects-1.0Defining classes-and-objects-1.0
Defining classes-and-objects-1.0
BG Java EE Course
 
05 Object Oriented Concept Presentation.pptx
05 Object Oriented Concept Presentation.pptx05 Object Oriented Concept Presentation.pptx
05 Object Oriented Concept Presentation.pptx
ToranSahu18
 
Esoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basicsEsoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basics
Rasan Samarasinghe
 
OOPS JavaScript Interview Questions PDF By ScholarHat
OOPS JavaScript Interview Questions PDF By ScholarHatOOPS JavaScript Interview Questions PDF By ScholarHat
OOPS JavaScript Interview Questions PDF By ScholarHat
Scholarhat
 
14. Java defining classes
14. Java defining classes14. Java defining classes
14. Java defining classes
Intro C# Book
 
Constructor&method
Constructor&methodConstructor&method
Constructor&method
Jani Harsh
 
Modeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based GamesModeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based Games
Ray Toal
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
MuhammadTalha436
 
Programming with Java: the Basics
Programming with Java: the BasicsProgramming with Java: the Basics
Programming with Java: the Basics
Jussi Pohjolainen
 
Ad

More from Jussi Pohjolainen (20)

Moved to Speakerdeck
Moved to SpeakerdeckMoved to Speakerdeck
Moved to Speakerdeck
Jussi Pohjolainen
 
Java Web Services
Java Web ServicesJava Web Services
Java Web Services
Jussi Pohjolainen
 
Box2D and libGDX
Box2D and libGDXBox2D and libGDX
Box2D and libGDX
Jussi Pohjolainen
 
libGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and Preferences
Jussi Pohjolainen
 
libGDX: Tiled Maps
libGDX: Tiled MapslibGDX: Tiled Maps
libGDX: Tiled Maps
Jussi Pohjolainen
 
libGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame Animation
Jussi Pohjolainen
 
Intro to Building Android Games using libGDX
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDX
Jussi Pohjolainen
 
Advanced JavaScript Development
Advanced JavaScript DevelopmentAdvanced JavaScript Development
Advanced JavaScript Development
Jussi Pohjolainen
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Jussi Pohjolainen
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
Jussi Pohjolainen
 
libGDX: Scene2D
libGDX: Scene2DlibGDX: Scene2D
libGDX: Scene2D
Jussi Pohjolainen
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
Jussi Pohjolainen
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
Jussi Pohjolainen
 
libGDX: User Input
libGDX: User InputlibGDX: User Input
libGDX: User Input
Jussi Pohjolainen
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDX
Jussi Pohjolainen
 
Building Android games using LibGDX
Building Android games using LibGDXBuilding Android games using LibGDX
Building Android games using LibGDX
Jussi Pohjolainen
 
Android Threading
Android ThreadingAndroid Threading
Android Threading
Jussi Pohjolainen
 
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesCreating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Jussi Pohjolainen
 
Creating Games for Asha - platform
Creating Games for Asha - platformCreating Games for Asha - platform
Creating Games for Asha - platform
Jussi Pohjolainen
 
Intro to Asha UI
Intro to Asha UIIntro to Asha UI
Intro to Asha UI
Jussi Pohjolainen
 
libGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and Preferences
Jussi Pohjolainen
 
libGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame Animation
Jussi Pohjolainen
 
Intro to Building Android Games using libGDX
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDX
Jussi Pohjolainen
 
Advanced JavaScript Development
Advanced JavaScript DevelopmentAdvanced JavaScript Development
Advanced JavaScript Development
Jussi Pohjolainen
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
Jussi Pohjolainen
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
Jussi Pohjolainen
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDX
Jussi Pohjolainen
 
Building Android games using LibGDX
Building Android games using LibGDXBuilding Android games using LibGDX
Building Android games using LibGDX
Jussi Pohjolainen
 
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesCreating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Jussi Pohjolainen
 
Creating Games for Asha - platform
Creating Games for Asha - platformCreating Games for Asha - platform
Creating Games for Asha - platform
Jussi Pohjolainen
 

Recently uploaded (20)

cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent IntegrationPyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too LateKubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
How to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptxHow to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptx
Version 1 Analytics
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUEIntroduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent IntegrationPyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too LateKubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
How to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptxHow to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptx
Version 1 Analytics
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 

Object Oriented Programming with Java

  • 1. Object Orientated Programming with Java Jussi Pohjolainen Tampere University of Applied Sciences
  • 3. Job Opportunities? Little acronyms from job descriptions: S60, C++, J2ME, Java, Java EE, SCRUM, JAX-WS 2.0, EJB 3.0, Spring, Hybernate, Struts, SQL, XHTML, CSS, Symbian C++, Perl, PHP, Python, LDAP, MFC, XML, .NET, Visual Basic, AJAX, Objective-C, JSP, Servlet, GTK, Qt, JavaScript, Oracle, SQL Server, DB Design… Where is Object Orientated programming?
  • 4. Developing S60 apps? “ Basic” programming skills OO skills Data Structures / DB UI programming Symbian C++ S60
  • 5. Developing iPhone apps? “ Basic” programming skills OO skills Data Structures / DB UI programming Objective-C iPhone
  • 6. Web-development with Java? “ Basic” programming skills OO skills Data Structures /DB UI programming Java Servlet Www-techniques: Xhtml, CSS, XML Applets JSP
  • 8. Intro to OO Object Orientated programming is a programming paradigm. One way of describing the structure of the application Several paradigms available. Procedural, Functional, ... OO is nowdays one of the most popular. C++ Java C# PHP 5 ...
  • 9. Benefits Reusability Once you written code, you can reuse it! Management Application is programmed using classes and objects. Pieces that communicate with each other. Maintanence When changing the code, it does not influence the whole application.
  • 10. Basic Concept: Object In real life, the world consists of objects: cars, buildings, trees, ships, humans, flowers.. Every object has actions (=methods!) that can incluence other objects jack drives ferrari. Object jack has a method drive that influences some way to object ferrari. jack.drive(ferrari); In OO, you should implement the app so that it consists of objects that influence each other!
  • 11. Example about an Object Datsun 100A is an object Datsun 100A has different actions or methods : drive, brake, park... Datsun 100A has information or attributes : color, amount of gears, amount of doors...
  • 12. Basic Concept: Class Class is a blueprint or template of an object Class describes the state and behaviour to it's objects. Object is created from the class.
  • 13. Example about an Class If Datsun 100A is an object, Car is a class. If one wants to create Datsun 100A, you have to have first the blueprints of the Datsun. Blueprints of an object: Class Class Car -> Object Datsun 100A
  • 14. Examples: Class to Object Class Object Car datsun 100a Human Jack Bauer Color red Laptop MacBook Pro String &quot;some string&quot; Array {1,2,3,2,4} ... ...
  • 15. Class and Object Car - class Datsun 100A Lamborghini Diablo Peugeot 406
  • 16. Car's Blueprint When building a Car's blueprint (class), you have to think that what is similar in all car's So what is similar in datsun, lamborghini and peugeot?
  • 17. Objects datsun, lambo, peugeot datsun: brand: Datsun 100A , motor: 1.0, fuzzy dices: yes, color: red lambo brand: Lamborghini Diablo, motor: 8.0, fuzzy dices: no, color: punainen peugeot brand: Peugeot 406, motor: 2.2, fuzzy dices: no, color: blue
  • 18. Car's Blueprint (Class) in UML Car brand motor amountOfDoors color hasFuzzyDices . .
  • 19. From Class to Object datsun Datsun 100A 1.0 3 red true lambo Lamborghini Diablo 8.0 3 red false Car brand motor amountOfDoors color hasFuzzyDices . .
  • 20. Car-class, extension Car brand motor amountOfDoors color hasFuzzyDices drive park brake
  • 21. Class Class is a template or blueprint to object Class holds Attributes (=variables) Actions (=methods) Class instances are called objects
  • 23. Person Class to Objects george George Smith 40 Teacher 09-12345 Jack Jack Puupää 60 Toimistopäällikkö 03-654321 eat sleep drinkBeer Person firstname lastname age profession phonenumber eat sleep drinkBeer
  • 24. Person – class to Java class Person { public String firstname; public String lastname; public int age; public String profession; public int phonenumber; public void eat() { System.out.println(&quot;Eating!&quot;); } public void sleep() { System.out.println(&quot;Sleeping!&quot;); } public void drinkBeer() { System.out.println(&quot;Drinking!&quot;); } } Person firstname lastname age profession phonenumber eat sleep drinkBeer
  • 25. From Class to Object App always starts from the main-method Let's test the Person – class This creates a variable a which type is integer int a; This creates a object jack which type is Person Person jack;
  • 26. From Class to Object class Person { .... } class JustTesting { public static void main(String [] args) { // Declare the object Person jack; // Initialize the object jack = new Person(); jack.firstname = &quot;Jack&quot;; jack.lastname = &quot;Smith&quot;; jack.drinkBeer(); } }
  • 27. Example: Car - class class Car { public String brand; public int amountOfGas; public void drive() { amountOfGas--; } }
  • 28. Creating Objects From the Class class Car { .... } class JustTesting { public static void main(String [] args) { Car datsun = new Car(); datsun.amountOfGas = 100; datsun.drive(); System.out.println(datsun.amountOfGas); Car ferrari = new Car(); ferrari.amountOfGas = 300; ferrari.drive(); System.out.println(ferrari.amountOfGas); } }
  • 29. Basic Concept - Encapsulation private public method
  • 30. About Attributes Attributes are usually marked as private The reason for this is that other objects cannot change the values as they will You don't for example want that every object in the world can change person's weight to 500kg...
  • 31. Example: Person - class class Person { private String name; private int weight; }
  • 32. class Person { private String name; private int weight; } class JustTesting { public static void main(String [] args) { Person jack = new Person(); jack.name = &quot;Jack Smith&quot;; jack.weight = 500; } } RESULT: TB308POHJUS-L-2:temp pohjus$ javac Person.java Person.java:9: name has private access in Person jack.name = &quot;Jack Smith&quot;; ^ Person.java:10: weight has private access in Person jack.weight = 500; ^ 2 errors
  • 33. class Person { private String name; private int weight; public void setName(String n) { name = n; } public String getName() { return name; } public void setWeight(int w) { if(w > 0 && w <= 150) weight = w; } public int getWeight() { return weight; } } class JustTesting { public static void main(String [] args) { Person jack = new Person(); jack.setName(&quot;Jack Smith&quot;); jack.setWeight(200); System.out.println(jack.getName()); } }
  • 34. Accessor and Mutator - methods class Person { private String name; private int weight; // Mutator public void setName(String n) { name = n; } // Accessor public String getName() { return name; } // Mutator public void setWeight(int w) { if(w > 0 && w <= 150) weight = w; } // Accessor public int getWeight() { return weight; } }
  • 36. Java Types Java has two type of types 1) Primitive types byte, short, int, long, double, float, char, boolean 2) Class types String, Scanner, Array, JButton, JFrame ...
  • 37. Differences Primitive types are spelled with lowercase: int, double, float... Class types are spelled with uppercase String, Scanner, Person, Cat, Car ... Primitive type declaring and initialization int a = 5; Class type declaring and initialization with new Dog spot = new Dog();
  • 38. Differences Primitive type int a = 5; Class type int [] b= new int[5]; b holds memory address a holds value 5.
  • 39. Memory Address? int [] b = new int[2]; b[0] = 1; b[1] = 2; // prints 0x01 System.out.println(b); RAM variable b address value 0x01 1 0x02 2 address value 0x09 0x01
  • 40. Memory Address? int [] b = new int[2]; b[0] = 1; b[1] = 2; int [] a = b; // prints 0x01 System.out.println(b); // prints 0x01 System.out.println(a); RAM variable b variable a address value 0x01 1 0x02 2 address value 0x09 0x01 address value 0x19 0x01
  • 41. Output? int [] b = new int[2]; b[0] = 1; b[1] = 2; int [] a = b; b[0] = 99; // Output? System.out.println(a[0]);
  • 42. Differences Again Primitive type int a = 5; Class type int [] b= new int[5]; b holds memory address a holds value 5.
  • 43. Differences Again Primitive type int a = 5; Class type Person jack = new Person() jack holds memory address a holds value 5.
  • 44. Output? Person jack = new Person(); jack.setName(&quot;Jack Smith&quot;); Person james = jack; james.setName(&quot;James Bond&quot;); // output? System.out.println(jack.getName());
  • 45. Methods and Variables public void method(int x) { x++; } public void main(String [] args) { int y = 3; method(y); // Output is 3! System.out.println(y); }
  • 46. Methods and Variables public void method(int [] x) { x[0] = 12; } public void main(String [] args) { int [] y = {1,2,3}; method(y); // Output is 12 since array is class type! System.out.println(y[0]); }
  • 47. String String is an exception to the rules String is a class type that acts like primitive type String is the only class type that can be initialized without the new word. String a = &quot;hello&quot;; String is passed by value in methods, so String is copied when moving strings in methods.
  • 48. String and Memory String variables are objects => holds memory address. Comparing contents a.equals(b); Comparing memory addresses a == b
  • 50. Constructors Constructor is a “init method” that is called when an object is created Java provides default constructor (= constructor with no parameters) Constructor has the same name than the class Constructor does not return anything Constructor usually initalizes class members
  • 51. Example class Car { public Car() { System.out.println(&quot;Constructor!&quot;); } } class Test { public static void main(String [] args) { Car datsun = new Car(); } } > java Test Constructor!
  • 52. class Car { private String brand; public Car(String b) { brand = b; } public String getBrand() { return brand; } } class Test { public static void main(String [] args) { Car datsun = new Car(&quot;Datsun 100A&quot;); System.out.println( datsun.getBrand() ); } } > java Test Datsun 100A
  • 53. Multiple Constructors class Car { public Car() { // Do something } public Car(String brand) { // Do something else } } class Test { public static void main(String [] args) { Car datsun = new Car(); Car ferrari = new Car(&quot;Ferrari&quot;); } }
  • 54. Problem? class Car { String brand; public Car(String brand) { brand = brand; } } class Test { public static void main(String [] args) { Car datsun = new Car(&quot;Datsun 100a&quot;); } } > java Test null
  • 55. Solution class Car { String brand; public Car(String brand) { this.brand = brand; } } class Test { public static void main(String [] args) { Car datsun = new Car(&quot;Datsun 100a&quot;); } } > java Test Datsun 100a
  • 57. Composition Relatioship between objects, where one object owns, or has the other object Car has or owns Motor When Car is build, it's motor is built also When Car is destroyed it's motor is destroyed
  • 59. Java: Composition // Composition class Car { private Motor motor; public Car() { motor = new Motor(); } }
  • 61. Java: One to Many class Department { private Professor [] members; private int numberOfMembers; public Department(Professor prof) { members = new Professor[20]; members[0] = prof; numberOfMembers = 1; } public void addProfessor(Professor prof) { members[numberOfMembers] = prof; numberOfMembers++; } }
  • 63. Introduction to Inheritance Inheritance is a relationship between two or more classes where derived class inherites behaviour and attributes of pre-existing (base) classes Intended to help reuse of existing code with little or no modification
  • 64. Inheritance Inheritance can be continous Derived class can inherit another class, which inherits another class and so on When changing the base class all the derived classes changes also Example: Mammal <– Human <– Worker <- Programmer Could mammal be a derived class? If so, what would be the base class?
  • 65. Picture about Inheritance C lass B F eatures: a,b,c C lass D F eatures: a,b,d,e,f a b C lass A features: a,b c d e C lass C F eatures: a,b,d,e f
  • 66. Multiple Inheritance In multiple inheritance a derived class has multiple base classes C++ supports multiple base classes, Java don't Driver - license - Y ear of approval Conductor - A ccount number Taxi Driver - area House Boat Houseboat
  • 67. Inheritance and Capsulation private Is accessible only via the base class public Is accessible everywhere (base class, derived class, othe classes) protected Is accessible by the base class and derived classes
  • 68. Basic example What are Programmer's attributes and methods? Human string name void sleep() void drink() void eat() Programmer int salary void implementApps() void beNerd()
  • 69. Overriding? What about now? Human string name void sleep() void drink() void eat() Programmer int salary void implementApps() void beNerd() void drink() void eat()
  • 70. Overriding Since programmer eats and drinks differently than humans (only Coke and Pizza) the eat and drink methods are overriden in Programmer!
  • 71. Abstract Class Abstract class is a class which you cannot instantiate (create objects) You can inherit abstract class and create objects from the inherited class, if it is concrete one Abstract class in C++ has abstract methods, that do not have implementations These methods forces derived classes to implement those methods
  • 72. Example <<abstract>> Mammal string name void makesound() {abstract} Elephant int trunkLength makesound()
  • 73. Example <<abstract>> Figure int x, y double calculateArea() {abstract} Circle double radius double calculateArea() Rect double length, height double calculateArea()
  • 75. Example: Basic Inheritance class Human { public void sleep() { System.out.println(&quot;Human sleeps&quot;); } } class Programmer extends Human { } class Test { public static void main(String [] args) { Programmer jussi = new Programmer(); jussi.sleep(); // &quot;Human sleeps&quot; } }
  • 76. Example: Overriding class Human { public void sleep() { System.out.println(&quot;Human sleeps&quot;); } } class Programmer extends Human { public void sleep() { System.out.println(&quot;Programmer sleeps&quot;); } } class Test { public static void main(String [] args) { Programmer jussi = new Programmer(); jussi.sleep(); // &quot;Programmer sleeps&quot; } }
  • 77. Example: super class Human { public void sleep() { System.out.println(&quot;Human sleeps&quot;); } } class Programmer extends Human { public void sleep() { super.sleep(); System.out.println(&quot;Programmer sleeps&quot;); } } class Test { public static void main(String [] args) { Programmer jussi = new Programmer(); jussi.sleep(); } } > java Test Human sleeps Programmer sleeps
  • 78. Constructors and Inheritance class Human { public Human() { System.out.println(&quot;Human&quot;); } } class Programmer extends Human { public Programmer() { System.out.println(&quot;Programmer&quot;); } } class Test { public static void main(String [] args) { Programmer jussi = new Programmer(); } } > java Test Human Programmer
  • 79. Constructors and Inheritance Constructor allways calls the base classes constructor! When creating a constructor void Human() { } Java adds super() – call to it: void Human() { super(); // calls base classes constructor }
  • 80. class Human { public Human() { System.out.println(&quot;Human&quot;); } } class Programmer extends Human { public Programmer() { System.out.println(&quot;Programmer&quot;); } } class Test { public static void main(String [] args) { Programmer jussi = new Programmer(); } } > java Test Human Programmer
  • 81. class Human { public Human() { super(); // Java adds this! Calls base classes contructor System.out.println(&quot;Human&quot;); } } class Programmer extends Human { public Programmer() { super(); // Java adds this! Calls base classes contructor System.out.println(&quot;Programmer&quot;); } } class Test { public static void main(String [] args) { Programmer jussi = new Programmer(); } } > java Test Human Programmer
  • 82. What the...? What base class? class Human { public Human() { // Java adds this! Calls base classes contructor super(); System.out.println(&quot;Human&quot;); } }
  • 83. Object Every class derives from a class called Object. // Java adds the extends Object too! class Human extends Object { public Human() { super(); System.out.println(&quot;Human&quot;); } }
  • 84. Object clone() equals() finalize() toString() ... Human String name ... http://java.sun.com/javase/6/docs/api/java/lang/Object.html
  • 85. class Human { public Human( int a ) { System.out.println(&quot;Human&quot;); } } class Programmer extends Human { public Programmer() { System.out.println(&quot;Programmer&quot;); } } class Test { public static void main(String [] args) { Programmer jussi = new Programmer(); } } > javac Test.java > DOES NOT COMPILE!!! Why?
  • 86. class Human { public Human( int a ) { System.out.println(&quot;Human&quot;); } } class Programmer extends Human { public Programmer() { super(); // Java adds this and it calls constructor // Human() that does not exist.. System.out.println(&quot;Programmer&quot;); } } class Test { public static void main(String [] args) { Programmer jussi = new Programmer(); } }
  • 87. class Human { public Human( int a ) { System.out.println(&quot;Human&quot;); } } class Programmer extends Human { public Programmer() { super(5); // Now it works: Human(int a) exists. System.out.println(&quot;Programmer&quot;); } } class Test { public static void main(String [] args) { Programmer jussi = new Programmer(); } }
  • 88. class Human { private String name public Human( String name ) { this.name = name; } } class Programmer extends Human { private int salary; public Programmer(String name, int salary) { super(name); this.salary = salary; } } class Test { public static void main(String [] args) { Programmer jussi = new Programmer(&quot;Jussi&quot;, 5000); } }
  • 89. Abstract Class From abstract class you cannot create objects! Abstract class is usually used with inheritance Abstract class may contain abstract methods. Abstract method forces derived classes to implement the abstract method.
  • 90. Abstract Class: example abstract class Mammal { abstract void makeSound(); } class Dog extends Mammal { // You have to implement this! public void makeSound() { System.out.println(&quot;Bark!&quot;); } }
  • 91. Abstract Class: example // Does NOT work, since Mammal is // abstract class Mammal object = new Mammal(); // Does work Dog spot = new Dog();
  • 92. Java: Abstract class and Interface Abstract class can hold &quot;normal&quot; methods and abstract methods. Interface holds only abstract methods Abstract class: class A extends someAbstractClass Interface class A implements someInterface
  • 93. Abstract class to Interface abstract class Movable { abstract public void start(); abstract public void stop(); }  interface Movable { public void start(); public void stop(); }
  • 94. Implementing the Interface interface Movable { public void start(); public void stop(); } class Car implements Movable { // You have to implement these public void start() { // Do something } public void stop() { // Do something } }
  • 95. Abstract class vs Interface Abstract class can hold normal methods and abstract methods Interface can hold only abstract methods Class can inherite only one base class Class can implement several interfaces!
  • 96. class Car extends Vehicle implements Movable, RunsOnGasoline { // You have to implement these public void start() { // Do something } public void stop() { // Do something } public void reduceGasoline() { // Do something } public void addGasoline() { // Do something   } }
  • 98. int as parameter class Exercise13 { public static void main(String [] args) { int x = 4; myMethod(x); } public static void myMethod(int a) { } }
  • 99. Human parameter class Human { } class Exercise13 { public static void main(String [] args) { Human jack = new Human(); myMethod(jack); } public static void myMethod(Human a) { } }
  • 100. Mammal parameter class Mammal { } class Human extends Mammal { } class Dog extends Mammal { } class Exercise13 { public static void main(String [] args) { Human jack = new Human(); Dog spot = new Dog(); Mammal mammal = new Mammal(); // these work! You can pass mammals, dogs and humans to the method! myMethod(jack); myMethod(dog); myMethod(mammal); } public static void myMethod(Mammal a) { } }
  • 101. Object parameter ... class Exercise13 { public static void main(String [] args) { Human jack = new Human(); Dog spot = new Dog(); Mammal mammal = new Mammal(); // these work! You can pass every object to the method myMethod(jack); myMethod(dog); myMethod(mammal); myMethod(&quot;hello&quot;); // String } public static void myMethod(Object a) { } }
  • 102. Calling methods from Mammal class Mammal { } class Human extends Mammal { public void bark() { System.out.println(&quot;Bark!&quot;); }; } class Dog extends Mammal { } class Exercise13 { public static void main(String [] args) { Human jack = new Human(); Dog spot = new Dog(); Mammal mammal = new Mammal(); myMethod(jack); myMethod(dog); myMethod(mammal); } public static void myMethod(Mammal a) { a.bark(); // Why this does not work? } }
  • 103. Solution class Exercise13 { public static void main(String [] args) { Human jack = new Human(); Dog spot = new Dog(); Mammal mammal = new Mammal(); myMethod(jack); myMethod(dog); myMethod(mammal); } public static void myMethod(Mammal a) { // Now it works if(a instanceof Dog) { Dog spot = (Dog) a; spot.bark(); } } }
  • 104. This works, why? class Mammal { public void giveBirth() { System.out.println(&quot;Giving birth&quot;); }; } class Human extends Mammal { } class Dog extends Mammal { } class Exercise13 { public static void main(String [] args) { Human jack = new Human(); Dog spot = new Dog(); Mammal mammal = new Mammal(); myMethod(jack); myMethod(dog); myMethod(mammal); } public static void myMethod(Mammal a) { a.giveBirth(); // Why this works? } }
  • 105. class Movable { public void start(); public void stop(); } class Vehicle { } class Car extends Vehicle implements Movable { public void start() { // Do something   } public void stop() { // Do something   } } class Exercise13 { public static void main(String [] args) { Car c = new Car(); myMethod(c); } // You can pass every object that implements the Movable! public static void myMethod( Movable a ) { a.start(); } }

Editor's Notes