Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. public class MaisSobreAHeranca {
  2. public void Run() {
  3. _Filho pessoa = new _Filho();
  4. pessoa.Informacao();
  5. pessoa.ComidaPreferida();
  6. }
  7. }
  8.  
  9. class _Pai {
  10. protected String ultimoNome = "Silva";
  11.  
  12. public void ComidaPreferida() {
  13. System.out.println("A minha comida preferida é arroz de marisco!");
  14. }
  15. }
  16.  
  17. class _Filho extends _Pai {
  18. private String primeiroNome = "Nelson";
  19. private int idade = 21;
  20.  
  21. public void Informacao() {
  22. System.out.println(new StringBuilder().append("Nome: ").append(primeiroNome).append(' ').append(ultimoNome));
  23. System.out.println(new StringBuilder().append("Idade: ").append(idade));
  24. }
  25.  
  26. @Override
  27. public void ComidaPreferida() {
  28. System.out.println("A minha comida preferida é lasanha!");
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement