Inherit with java

You can do the class inherit other like this: 

class NomeDaClasseASerCriada extends NomeDaClasseASerHerdada

We show an sample:

Class 1: Eletrodomestico

package tiexpert;

public class Eletrodomestico {
private boolean ligado;
private int voltagem;
private int consumo;
public Eletrodomestico(boolean ligado, int voltagem, int consumo) {
  this.ligado = ligado;
  this.voltagem = voltagem;
  this.consumo = consumo;
  }
// (...)
}
Class 2: TV
package tiexpert;

public class TV extends Eletrodomestico {
private int canal;
private int volume;
private int tamanho;
public TV(int voltagem, int consumo, int canal, int volume, int tamanho) {
  super(false, voltagem, consumo);
  this.canal = canal;
  this.volume = volume;
  this.tamanho = tamanho;
 }
 //(...)
}
Instance:
package tiexpert;

public class ExemploHeranca {
  public static void mostrarCaracteristicas(TV obj) {
   System.out.print("Esta TV tem as seguintes características:\n"
   + "Tamanho: " + obj.getTamanho() + "\"\n"
   + "Voltagem Atual: "+ obj.getVoltagem() + "V\n"
   + "Consumo/h: " + obj.getConsumo() + "W\n");
   if (obj.isLigado()) {
    System.out.println("Ligado: Sim\n"
   + "Canal: " + obj.getCanal() + "\n"
   + "Volume: " + obj.getVolume()+"\n");
   } else {
  System.out.println("Ligado: Não\n");
 }
}
public static void main(String args[]) {
  TV tv1 = new TV(110950021);
  TV tv2 = new TV(2201270029);
  tv2.setLigado(true);
  tv2.setCanal(3);
  tv2.setVolume(25);
  mostrarCaracteristicas(tv1);
  mostrarCaracteristicas(tv2);
 }
}
Let’s trainning !!
Font: http://www.tiexpert.net/programacao/java/heranca.php

Remember again about Classes

We define classes how groups of objects than they are grouped for have equallities of comportment and features and of differ structure of data, because they can duplicates and inherit forming the new classes.
For understanding the classes, we consider the need of to create a object CARRO, will list the features of a CARRO :

Name of object: Carro (model)
Features: Cor, marca (attributes)

Now, we see how declare a class in C#:

Class Carro
Public sCor As String
Public sMarca As String
End Class
But a class of will care all details of a car will are more very complex, it will have details of tires, engine, opcionals. For this, there is a inherited and the polymorphism for to easy the creation of new objects. See:

Class Pneu
Public iTamanho As Integer
Public iLargura As Integer
End Class

Class Carro
Inherits Pneu

Public sCor As String
Public sMarca As String
End Class

Class Caminhao
Inherits Pneu

Public sCor As String
Public sMarca As String
End Class

Class Onibus
Inherits Pneu

Public sCor As String
Public sMarca As String
End Class

Font: http://www.csharpbr.com.br/Portal/VisualizarArtigo.aspx?Artigo=64