SlideShare a Scribd company logo
1 of 4
Classes
https://docs.oracle.com/javase/tutorial/java/concepts/class.html
class Bicycle { CLASS
int cadence = 0;
int speed = 0; INITIAL INTEGERS
int gear = 1;
void changeCadence(int newValue) {
cadence = newValue;
}
void changeGear(int newValue) {
gear = newValue;
} DECLARING TO INTEGERS
void speedUp(int increment) {
speed = speed + increment;
}
void applyBrakes(int decrement) {
speed = speed - decrement;
}
void printStates() {
System.out.println("cadence:" +
cadence + " speed:" + PRINT OUT
speed + " gear:" + gear);
}
}
Inheritance
https://docs.oracle.com/javase/tutorial/java/concepts/inheritance.html
class MountainBike extends Bicycle {
// new fields and methods defining
// a mountain bike would go here
Can inherit traits from other forms of bikes
}
Interfaces
https://docs.oracle.com/javase/tutorial/java/concepts/interface.html
Bicycle as Interface
interface Bicycle {
// wheel revolutions per minute
void changeCadence(int newValue);
void changeGear(int newValue);
void speedUp(int increment);
void applyBrakes(int decrement);
}
Implementing Interface must include: the methods (changeGear, changeCadence,
speedUp, applyBrakes, etc)
class BRANDBicycle implements Bicycle {
int cadence = 0;
int speed = 0; INITIAL VARIABLE
int gear = 1;
// The compiler will now require that methods
// changeCadence, changeGear, speedUp, and applyBrakes
// all be implemented. Compilation will fail if those
// methods are missing from this class.
void changeCadence(int newValue) {
cadence = newValue;
}
void changeGear(int newValue) {
gear = newValue;
}
void speedUp(int increment) {
speed = speed + increment;
}
void applyBrakes(int decrement) {
speed = speed - decrement;
}
void printStates() {
System.out.println("cadence:" +
cadence + " speed:" +
speed + " gear:" + gear);
}
}
Questions
1. Real-world objects contain State and Behaviour.
2. A software object's state is stored in ___.
3. A software object's behaviour is exposed through ___.
4. Hiding internal data from the outside world and accessing it only through publicly exposed
methods is known as data ___.
5. A blueprint for a software object is called a ___.
6. Common behaviour can be defined in a ___ and inherited into a ___ using the ___ keyword.
7. A collection of methods with no implementation is called a ___.
8. A namespace that organizes classes and interfaces by functionality is called a ___.
9. The term API stands for ___?

More Related Content

Similar to Java tutorials

Guide to Generate Extent Report in Kotlin
Guide to Generate Extent Report in KotlinGuide to Generate Extent Report in Kotlin
Guide to Generate Extent Report in KotlinRapidValue
 
1 aleksandr gritsevski - attd example using
1   aleksandr gritsevski - attd example using1   aleksandr gritsevski - attd example using
1 aleksandr gritsevski - attd example usingIevgenii Katsan
 
SystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features SummarySystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features SummaryAmal Khailtash
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy codeShriKant Vashishtha
 
Writing SOLID C++ [gbgcpp meetup @ Zenseact]
Writing SOLID C++ [gbgcpp meetup @ Zenseact]Writing SOLID C++ [gbgcpp meetup @ Zenseact]
Writing SOLID C++ [gbgcpp meetup @ Zenseact]Dimitrios Platis
 
OOP with Java - Part 3
OOP with Java - Part 3OOP with Java - Part 3
OOP with Java - Part 3RatnaJava
 
Functional UIs with Java 8 and Vaadin JavaOne2014
Functional UIs with Java 8 and Vaadin JavaOne2014Functional UIs with Java 8 and Vaadin JavaOne2014
Functional UIs with Java 8 and Vaadin JavaOne2014hezamu
 
An Introduction to AngularJs Unittesting
An Introduction to AngularJs UnittestingAn Introduction to AngularJs Unittesting
An Introduction to AngularJs UnittestingInthra onsap
 
Pro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptPro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptSeok-joon Yun
 
EVERYTHING ABOUT STATIC CODE ANALYSIS FOR A JAVA PROGRAMMER
EVERYTHING ABOUT STATIC CODE ANALYSIS FOR A JAVA PROGRAMMEREVERYTHING ABOUT STATIC CODE ANALYSIS FOR A JAVA PROGRAMMER
EVERYTHING ABOUT STATIC CODE ANALYSIS FOR A JAVA PROGRAMMERAndrey Karpov
 
06 Java Language And OOP Part VI
06 Java Language And OOP Part VI06 Java Language And OOP Part VI
06 Java Language And OOP Part VIHari Christian
 
Chap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptxChap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptxchetanpatilcp783
 
Learn D3.js in 90 minutes
Learn D3.js in 90 minutesLearn D3.js in 90 minutes
Learn D3.js in 90 minutesJos Dirksen
 
Chap2 class,objects
Chap2 class,objectsChap2 class,objects
Chap2 class,objectsraksharao
 
Web components with java by Haijian Wang
Web components with java by Haijian WangWeb components with java by Haijian Wang
Web components with java by Haijian WangGWTcon
 
Build Widgets
Build WidgetsBuild Widgets
Build Widgetsscottw
 

Similar to Java tutorials (20)

Guide to Generate Extent Report in Kotlin
Guide to Generate Extent Report in KotlinGuide to Generate Extent Report in Kotlin
Guide to Generate Extent Report in Kotlin
 
1 aleksandr gritsevski - attd example using
1   aleksandr gritsevski - attd example using1   aleksandr gritsevski - attd example using
1 aleksandr gritsevski - attd example using
 
SystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features SummarySystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features Summary
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy code
 
Writing SOLID C++ [gbgcpp meetup @ Zenseact]
Writing SOLID C++ [gbgcpp meetup @ Zenseact]Writing SOLID C++ [gbgcpp meetup @ Zenseact]
Writing SOLID C++ [gbgcpp meetup @ Zenseact]
 
Java Quiz - Meetup
Java Quiz - MeetupJava Quiz - Meetup
Java Quiz - Meetup
 
OOP with Java - Part 3
OOP with Java - Part 3OOP with Java - Part 3
OOP with Java - Part 3
 
Functional UIs with Java 8 and Vaadin JavaOne2014
Functional UIs with Java 8 and Vaadin JavaOne2014Functional UIs with Java 8 and Vaadin JavaOne2014
Functional UIs with Java 8 and Vaadin JavaOne2014
 
An Introduction to AngularJs Unittesting
An Introduction to AngularJs UnittestingAn Introduction to AngularJs Unittesting
An Introduction to AngularJs Unittesting
 
Pro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptPro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScript
 
Java programs
Java programsJava programs
Java programs
 
EVERYTHING ABOUT STATIC CODE ANALYSIS FOR A JAVA PROGRAMMER
EVERYTHING ABOUT STATIC CODE ANALYSIS FOR A JAVA PROGRAMMEREVERYTHING ABOUT STATIC CODE ANALYSIS FOR A JAVA PROGRAMMER
EVERYTHING ABOUT STATIC CODE ANALYSIS FOR A JAVA PROGRAMMER
 
06 Java Language And OOP Part VI
06 Java Language And OOP Part VI06 Java Language And OOP Part VI
06 Java Language And OOP Part VI
 
Chap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptxChap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptx
 
Diifeerences In C#
Diifeerences In C#Diifeerences In C#
Diifeerences In C#
 
Learn D3.js in 90 minutes
Learn D3.js in 90 minutesLearn D3.js in 90 minutes
Learn D3.js in 90 minutes
 
Chap2 class,objects
Chap2 class,objectsChap2 class,objects
Chap2 class,objects
 
Web components with java by Haijian Wang
Web components with java by Haijian WangWeb components with java by Haijian Wang
Web components with java by Haijian Wang
 
Build Widgets
Build WidgetsBuild Widgets
Build Widgets
 
Data Mining using Weka
Data Mining using WekaData Mining using Weka
Data Mining using Weka
 

More from Mike Hughes

Unit 20 brief 1 task 2_worksheet (1)
Unit 20 brief 1 task 2_worksheet (1)Unit 20 brief 1 task 2_worksheet (1)
Unit 20 brief 1 task 2_worksheet (1)Mike Hughes
 
Y1 games ig2 learner assessment submission declaration blogger
Y1 games ig2 learner assessment submission declaration bloggerY1 games ig2 learner assessment submission declaration blogger
Y1 games ig2 learner assessment submission declaration bloggerMike Hughes
 
Task 2 analysis gears of war 3
Task 2 analysis gears of war 3Task 2 analysis gears of war 3
Task 2 analysis gears of war 3Mike Hughes
 
Task 2 analysis dead space 3
Task 2 analysis dead space 3Task 2 analysis dead space 3
Task 2 analysis dead space 3Mike Hughes
 
Task 2 analysis halo 4
Task 2 analysis halo 4Task 2 analysis halo 4
Task 2 analysis halo 4Mike Hughes
 
Task 2 analysis modern warfare 3
Task 2 analysis modern warfare 3Task 2 analysis modern warfare 3
Task 2 analysis modern warfare 3Mike Hughes
 
Gears of war analysis
Gears of war analysisGears of war analysis
Gears of war analysisMike Hughes
 
Task 2 analysis gears of war 3
Task 2 analysis gears of war 3Task 2 analysis gears of war 3
Task 2 analysis gears of war 3Mike Hughes
 
Task 2 analysis halo 4
Task 2 analysis halo 4Task 2 analysis halo 4
Task 2 analysis halo 4Mike Hughes
 
Programming my sounds into my game
Programming my sounds into my gameProgramming my sounds into my game
Programming my sounds into my gameMike Hughes
 
Ciriculum virtae
Ciriculum virtaeCiriculum virtae
Ciriculum virtaeMike Hughes
 
HA7 Assignment Brief MPH
HA7 Assignment Brief MPHHA7 Assignment Brief MPH
HA7 Assignment Brief MPHMike Hughes
 
Sidekick MPH Robot Companion
Sidekick MPH Robot CompanionSidekick MPH Robot Companion
Sidekick MPH Robot CompanionMike Hughes
 
L3 gd ha8_sidekick_040315_01
L3 gd ha8_sidekick_040315_01L3 gd ha8_sidekick_040315_01
L3 gd ha8_sidekick_040315_01Mike Hughes
 
Robot companion MPH
Robot companion MPHRobot companion MPH
Robot companion MPHMike Hughes
 
Task 2 analysis the last of us
Task 2 analysis the last of usTask 2 analysis the last of us
Task 2 analysis the last of usMike Hughes
 

More from Mike Hughes (20)

Unit 20 brief 1 task 2_worksheet (1)
Unit 20 brief 1 task 2_worksheet (1)Unit 20 brief 1 task 2_worksheet (1)
Unit 20 brief 1 task 2_worksheet (1)
 
Update log
Update logUpdate log
Update log
 
Y1 games ig2 learner assessment submission declaration blogger
Y1 games ig2 learner assessment submission declaration bloggerY1 games ig2 learner assessment submission declaration blogger
Y1 games ig2 learner assessment submission declaration blogger
 
Sound equipment
Sound equipmentSound equipment
Sound equipment
 
Sound equipment
Sound equipmentSound equipment
Sound equipment
 
Task 2 analysis gears of war 3
Task 2 analysis gears of war 3Task 2 analysis gears of war 3
Task 2 analysis gears of war 3
 
Task 2 analysis dead space 3
Task 2 analysis dead space 3Task 2 analysis dead space 3
Task 2 analysis dead space 3
 
Task 2 analysis halo 4
Task 2 analysis halo 4Task 2 analysis halo 4
Task 2 analysis halo 4
 
Task 2 analysis modern warfare 3
Task 2 analysis modern warfare 3Task 2 analysis modern warfare 3
Task 2 analysis modern warfare 3
 
Gears of war analysis
Gears of war analysisGears of war analysis
Gears of war analysis
 
Task 2 analysis gears of war 3
Task 2 analysis gears of war 3Task 2 analysis gears of war 3
Task 2 analysis gears of war 3
 
Task 2 analysis halo 4
Task 2 analysis halo 4Task 2 analysis halo 4
Task 2 analysis halo 4
 
Programming my sounds into my game
Programming my sounds into my gameProgramming my sounds into my game
Programming my sounds into my game
 
Ciriculum virtae
Ciriculum virtaeCiriculum virtae
Ciriculum virtae
 
HA7 Assignment Brief MPH
HA7 Assignment Brief MPHHA7 Assignment Brief MPH
HA7 Assignment Brief MPH
 
Sidekick MPH Robot Companion
Sidekick MPH Robot CompanionSidekick MPH Robot Companion
Sidekick MPH Robot Companion
 
L3 gd ha8_sidekick_040315_01
L3 gd ha8_sidekick_040315_01L3 gd ha8_sidekick_040315_01
L3 gd ha8_sidekick_040315_01
 
Mood board MPH
Mood board MPHMood board MPH
Mood board MPH
 
Robot companion MPH
Robot companion MPHRobot companion MPH
Robot companion MPH
 
Task 2 analysis the last of us
Task 2 analysis the last of usTask 2 analysis the last of us
Task 2 analysis the last of us
 

Java tutorials

  • 1. Classes https://docs.oracle.com/javase/tutorial/java/concepts/class.html class Bicycle { CLASS int cadence = 0; int speed = 0; INITIAL INTEGERS int gear = 1; void changeCadence(int newValue) { cadence = newValue; } void changeGear(int newValue) { gear = newValue; } DECLARING TO INTEGERS void speedUp(int increment) { speed = speed + increment; } void applyBrakes(int decrement) { speed = speed - decrement; } void printStates() { System.out.println("cadence:" + cadence + " speed:" + PRINT OUT speed + " gear:" + gear); } } Inheritance https://docs.oracle.com/javase/tutorial/java/concepts/inheritance.html class MountainBike extends Bicycle { // new fields and methods defining // a mountain bike would go here Can inherit traits from other forms of bikes }
  • 2. Interfaces https://docs.oracle.com/javase/tutorial/java/concepts/interface.html Bicycle as Interface interface Bicycle { // wheel revolutions per minute void changeCadence(int newValue); void changeGear(int newValue); void speedUp(int increment); void applyBrakes(int decrement); }
  • 3. Implementing Interface must include: the methods (changeGear, changeCadence, speedUp, applyBrakes, etc) class BRANDBicycle implements Bicycle { int cadence = 0; int speed = 0; INITIAL VARIABLE int gear = 1; // The compiler will now require that methods // changeCadence, changeGear, speedUp, and applyBrakes // all be implemented. Compilation will fail if those // methods are missing from this class. void changeCadence(int newValue) { cadence = newValue; } void changeGear(int newValue) { gear = newValue; } void speedUp(int increment) { speed = speed + increment; } void applyBrakes(int decrement) { speed = speed - decrement; } void printStates() { System.out.println("cadence:" + cadence + " speed:" + speed + " gear:" + gear); } }
  • 4. Questions 1. Real-world objects contain State and Behaviour. 2. A software object's state is stored in ___. 3. A software object's behaviour is exposed through ___. 4. Hiding internal data from the outside world and accessing it only through publicly exposed methods is known as data ___. 5. A blueprint for a software object is called a ___. 6. Common behaviour can be defined in a ___ and inherited into a ___ using the ___ keyword. 7. A collection of methods with no implementation is called a ___. 8. A namespace that organizes classes and interfaces by functionality is called a ___. 9. The term API stands for ___?