Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Inheritance
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//'main' method must be in a class 'Rextester'. //openjdk version '11.0.5' import java.util.*; import java.lang.*; class Vehicle { int gear,speed; public Vehicle(int gear,int speed){ this.gear=gear; this.speed=speed; } public void applyBrakeToStop(int decrement){ if(decrement<=speed){ speed=speed-decrement; } } public void applyBrakeToIncrease(int increment){ speed=speed+increment; } public String toString(){ return("Speed is: "+speed + "\nThe Gear value is: "+gear); } } class Bicycle extends Vehicle { public int seatHeight; public Bicycle(int gear,int speed,int seatHeight){ super(gear,speed); this.seatHeight=seatHeight; } public void setseatHeight(int newValue){ seatHeight=newValue; } public String toString(){ return(super.toString() + "\nThe seat Height is: " +seatHeight+" foot"); } } class Rextester { public static void main(String args[]) { Bicycle b = new Bicycle(5,2000,2); System.out.println(b.toString()); } }
[
+
]
Show input
Compilation time: 1.32 sec, absolute running time: 0.34 sec, cpu time: 0.35 sec, memory peak: 39 Mb, absolute service time: 1,75 sec
edit mode
|
history
|
discussion
Speed is: 2000 The Gear value is: 5 The seat Height is: 2 foot