O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Revisão Sobre Programação Orientada a Objetos com Java

4.910 visualizações

Publicada em

Aula de revisão sobre Programação Orientada a Objetos com uso de Java para os exercícios e exemplos.
O código esta disponível no github.

Publicada em: Educação
  • Verifique a fonte ⇒ www.boaaluna.club ⇐. Este site me ajudou escrever uma monografia.
       Responder 
    Tem certeza que deseja  Sim  Não
    Insira sua mensagem aqui
  • DOWNLOAD THE BOOK INTO AVAILABLE FORMAT (New Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THE can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THE is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBOOK .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, CookBOOK, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, EBOOK, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THE Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THE the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THE Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Responder 
    Tem certeza que deseja  Sim  Não
    Insira sua mensagem aqui
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/qURD } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/qURD } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download doc Ebook here { https://soo.gd/qURD } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Responder 
    Tem certeza que deseja  Sim  Não
    Insira sua mensagem aqui
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://shorturl.at/krvUW } ......................................................................................................................... Download Full EPUB Ebook here { http://shorturl.at/krvUW } ......................................................................................................................... Download Full doc Ebook here { http://shorturl.at/krvUW } ......................................................................................................................... Download PDF EBOOK here { http://shorturl.at/krvUW } ......................................................................................................................... Download EPUB Ebook here { http://shorturl.at/krvUW } ......................................................................................................................... Download doc Ebook here { http://shorturl.at/krvUW } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Responder 
    Tem certeza que deseja  Sim  Não
    Insira sua mensagem aqui
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Responder 
    Tem certeza que deseja  Sim  Não
    Insira sua mensagem aqui

Revisão Sobre Programação Orientada a Objetos com Java

  1. 1. Linguagem Orientada a Objetos Revisão Mario Jorge Pereira mariojp@gmail.com
  2. 2. Orientação a Objetos / Java Ambiente Java Orientação a Objetos Tipos e Modificadores Fluxo de Controle Arrays Tratamento de Erro Aplicações Console Interface javax.swing Interface Eventos Aplicações Desktop
  3. 3. Ambiente Java JDK JRE Maquina Virtual Java (JVM) Coleta de Lixo Segurança do Código
  4. 4. Orientação a Objetos Características: Encapsulamento Ocultar elementos da implementação de uma classe, porém fornecendo uma interface publica para acesso. Herança Extensão Acrescenta novos métodos aos já herdados Sobreposição Redefine os métodos implementados previamente Polimorfismo Comportamentos diferentes para mesma mensagem a depender do tipo.
  5. 5. Palavras Chave
  6. 6. Tipos Primitivos
  7. 7. Wrapper String texto = "12.0"; int numero = Integer.parseInt(texto); Método: Integer.valueOf(String s) : int Integer.parseInt(String s) : Integer
  8. 8. Objetos Objetos são conceitos que têm identidade, estado e comportamento Pode-se pensar sobre o mundo real como uma coleção de objetos relacionados Características de OO: Um programa OO é objeto e é composto por objetos O programa OO são objetos se comunicando através de mensagens uns com os outros Os objeto possuem um tipo que descreve seus dados Objetos de tipos iguais podem receber as mesmas mensagens
  9. 9. Classes e Objetos
  10. 10. Classes Classes são uma especificação para objetos Uma classe define o que um objeto pode ter e o que ele pode fazer. A diferença entre classe e objeto: "Classe" é um gabarito (como a planta de uma casa) "Objeto" é a concretização do gabarito (casas feitas a partir da mesma planta) Resumindo: Classes não são os objetos que representam Classes definem lógica estática Classes não existem no contexto da execução
  11. 11. Declaração de Classes em Java [<declaracaoPacote>] [<declaracaoImport>] <modificadores> class <NomeClasse> { [<modificadores>] <tipo> <nome> = [<valorInicial>]; [<modificador>] <NomeClasse> ([<listaArgumentos>]) { [<instruções>] } [<modificadores>] <tipoRetorno> <nome> ([<listaArgumentos>]) { [<instruções>] } }
  12. 12. Declaração de Classes em Java package br.com.mariojp.veiculo; public class Carro { private double cargaMaxima = 50.5; private double cargaAtual; public Caro(){ cargaAtual = 10.5; } public double getCargaAtual(){ return cargaAtual; } public void setCarga(double peso){ cargaAtual = peso; } }
  13. 13. Fluxos de Controle if (expressão boleana) { instruções; } else { instruções; } for (inicializa; expressão booleana; altera) { instruções; }
  14. 14. Resumo Classe Definição (código fonte) de um objeto (instancia) Objeto Uma instancia de uma classe. Um objeto. Atributo Um elemento dados de um objeto. Variável de instancia. Método Um elemento de comportamento de um objeto. Um procedimento. Construtor “Similar a um método” usado para inicializar um novo objeto Pacote Agrupamento de Classes e/ou subpacotes
  15. 15. Array String names[]; names = new String[3]; names[0] = "Georgianna"; names[1] = "Jen"; names[2] = "Simon"; String names[] = { "Georgianna", "Jen", "Simon" }; Data data[]; datas = new Data[3]; dates[0] = new Data(22, 7, 1964); dates[1] = new Data(1, 1, 2000); dates[2] = new Data(22, 12, 1964); Data dates[] = { new Data(22, 7, 1964), new Data(1, 1, 2000), new Data(22, 12, 1964) };
  16. 16. Tratamento de Erros try { instruções onde pode ocorrer uma Exceção; } catch (Tipo de Exceção instancia_erro) { instruções caso ocorra a Exceção; } finally { instruções que vão ocorrer sempre; } declaracaoMetodo throws tipo Exceção{ instruções onde pode ocorrer uma Exceção; }
  17. 17. Exercício 1. Escreva uma classe Ponto contém x e y e que podem ser definidos em construtor Sobrescreva o metodo toString para retornar o x e o y 2. Escreva uma classe Circulo, que contenha raio inteiro e origem do tipo Ponto Dois construtores que define origem e raio Circulo(int x,int y, int raio) Cirtulo(Ponto ponto, int raio) método que retorna a área método que retorna a circunferência use java.lang.Math.PI (Math.PI) Sobrescreva o metodo toString para retornar o raio e a origem
  18. 18. Exercício 3. Escreva uma classe Teste com seguinte main: Ponto p1 = new Ponto(2,5); Circulo cir1 = new Circulo(p1,4); Circulo[] circulos = new Circulo[5]; circulos[0] = cir1; circulos[1] = new Circulo(new Ponto(1,2),5); circulos[2] = new Circulo(3,4,5); circulos[3] = new Circulo(1,1,6); circulos[4] = new Circulo(5,5,6); for( Circulo c : circulos ) { System.out.println(c); }
  19. 19. Exercício 4. Crie uma classe abstrata Figura que: - contém o atributo String cor e por padrão a cor “branco” - crie um método abstrato string desenhar() 5. Altere a classe Circulo para ela herdar de Figura - Faça as alterações necessárias - Implemente o método desenhar() retornando o nome da figura e a cor. - Implemente um construtor Circulo(String cor) 6. Crie uma classe Quadrado que herda de Figura e implemente o método desenhar(). -Implemente o construtor Quadrado(String cor) -Implemente o construtor Quadrado()
  20. 20. Exercício 7. Escreva uma classe Teste com seguinte main: Figura[] figuras = new Figura[5]; figuras[0] = new Quadrado(“Verde”); figuras[1] = new Circulo(“amarelo”); figuras[2] = new Circulo(); figuras[3] = new Quadrado(“azul”); figuras[4] = new Circulo(“preto”); for( Figura f : figuras ) { System.out.println(f.desenhar()); }
  21. 21. Formas de percorrer uma Coleção for(Iterator it = <colecao>.iterator() ;it.hasNext() ; ){ <Tipo> <referencia> (<Tipo>) it.next(); } Iterator it = <colecao>.iterator(); while (it.hasNext()){ <Tipo> <referencia> (<Tipo>) it.next(); } for( <Tipo> <referencia> : <coleção> ) { usar a <referencia>; } //JAVA 1.5

×