SlideShare uma empresa Scribd logo
1 de 21
Baixar para ler offline
OCPJP
Objetivo: Java Class Design
Questão
Dado:
1. public class base {
2. protected int blipvert(int x) { return 333; }
3. }
4. class sub extends base {
5. // insert code here
6. }
Quais 5 métodos inseridos independentemente na linha 5 irão compilar? (Escolha 5)
a. public int blipvert(int x) { return 0; }
b. private int blipvert(int x) { return 0; }
c. private int blipvert(long x) { return 0; }
d. protected long blipvert(int x) { return 0; }
e. protected int blipvert(long x) { return 0; }
f. protected long blipvert(long x) { return 0; }
g. protected long blipvert(int x, int y) { return 0; }
Questão Resolvida
Dado:
1. public class base {
2. protected int blipvert(int x) { return 333; }
3. }
4. class sub extends base {
5. // insert code here
6. }
Quais 5 métodos inseridos independentemente na linha 5 irão compilar? (Escolha 5)
a. public int blipvert(int x) { return 0; }
b. private int blipvert(int x) { return 0; }
c. private int blipvert(long x) { return 0; }
d. protected long blipvert(int x) { return 0; }
e. protected int blipvert(long x) { return 0; }
f. protected long blipvert(long x) { return 0; }
g. protected long blipvert(int x, int y) { return 0; }
Correto
Correto
Correto
Correto
Correto
Questão
Dado:
10. class Base {
11. void foo() { }
12. }
13. class Sub extends Base {
14. //insert method here
15. }
Quais 3 métodos, inseridos individualmente na linha 14 completarão corretamente a classe Sub (Escolha 3)
A. int foo() { /* more code here */ }
B. void foo() { /* more code here */ }
C. public void foo() { /* more code here */ }
D. private void foo() { /* more code here */ }
E. protected void foo() { /* more code here */ }
Questão Resolvida
Dado:
10. class Base {
11. void foo() { }
12. }
13. class Sub extends Base {
14. //insert method here
15. }
Quais 3 métodos, inseridos individualmente na linha 14 completarão corretamente a classe Sub (Escolha 3)
A. int foo() { /* more code here */ }
B. void foo() { /* more code here */ }
C. public void foo() { /* more code here */ }
D. private void foo() { /* more code here */ }
E. protected void foo() { /* more code here */ } Correto
Correto
Correto
Questão
11. class Foo{
12. public void process() { System.out.print("foo"); }
13. class Bar extends Foo {
14. public void process() throws IOException
15. {
16. System.out.print("Class bar");
17. throw new IOException();
18. }
19. public static void main(String[] args) {
20. try { new Bar().process(); }
21. catch (IOException e)
{ System.out.println("Not able to compete your request."); }
22. }
Qual é o resultado?
a. Exception
b. A,B,Exception
c. Compilation fails because of an error in line 20.
d. Compilation fails because of an error in line 14.
e. A NullPointerException is thrown at runtime.
Questão Resolvida
11. class Foo{
12. public void process() { System.out.print("foo"); }
13. class Bar extends Foo {
14. public void process() throws IOException
15. {
16. System.out.print("Class bar");
17. throw new IOException();
18. }
19. public static void main(String[] args) {
20. try { new Bar().process(); }
21. catch (IOException e)
{ System.out.println("Not able to compete your request."); }
22. }
Qual é o resultado?
a. Exception
b. A,B,Exception
c. Compilation fails because of an error in line 20.
d. Compilation fails because of an error in line 14.
e. A NullPointerException is thrown at runtime.
Correto
Questão
Dado:
1. class BasePizza {
2. java.util.ArrayList toppings;
3. public final void addTopping(String topping) {
4. toppings.add(topping);
5. }
6. }
7. public class PepperoniPizza extends BasePizza {
8. public void addTopping(String topping) {
9. System.out.println("Toppings not available");
10. }
11. public static void main(String[] args) {
12. BasePizza pizza = new PepperoniPizza();
13. pizza.addTopping("Mushrooms");
14. }
15. }
Qual é o resultado?
a. Compilation fails.
b. Toppings not available.
c. The code runs with no output.
d. A NullPointerException is thrown in Line 4.
Questão Resolvida
Dado:
1. class BasePizza {
2. java.util.ArrayList toppings;
3. public final void addTopping(String topping) {
4. toppings.add(topping);
5. }
6. }
7. public class PepperoniPizza extends BasePizza {
8. public void addTopping(String topping) {
9. System.out.println("Toppings not available");
10. }
11. public static void main(String[] args) {
12. BasePizza pizza = new PepperoniPizza();
13. pizza.addTopping("Mushrooms");
14. }
15. }
Qual é o resultado?
a. Compilation fails.
b. Toppings not available.
c. The code runs with no output.
d. A NullPointerException is thrown in Line 4.
Correto
Questão
Dado:
11. static class Foo {
12. void process() throws Exception {
13. System.out.println("Foo");
14. throw new Exception(); }
15. }
16. static class Bar extends Foo {
17. void process() { System.out.println("Bar"); }
18. }
19. public static void main(String[ ] args) {
20. new Bar().process();
21. }
Qual é o resultado?
A. Bar
B. The code runs with no output.
C. Compilation fails because of an error in line 12.
D. Compilation fails because of an error in line 15
E. Compilation fails because of an error in line 18.
Questão Resolvida
Dado:
11. static class Foo {
12. void process() throws Exception {
13. System.out.println("Foo");
14. throw new Exception(); }
15. }
16. static class Bar extends Foo {
17. void process() { System.out.println("Bar"); }
18. }
19. public static void main(String[ ] args) {
20. new Bar().process();
21. }
Qual é o resultado?
A. Bar
B. The code runs with no output.
C. Compilation fails because of an error in line 12.
D. Compilation fails because of an error in line 15
E. Compilation fails because of an error in line 18.
Correto
Questão
Dado:
11. class Base { public void foo() { System.out.print("Base "); } }
12.
13. public class Sub extends Base {
14. public void foo() throws RuntimeException {
15. super.foo();
16. if (true) throw new RuntimeException();
17. System.out.print("Sub ");
18. }
19. public static void main(String[] args) {
20. new Sub().foo();
21. }
22. }
Qual é o resultado?
a. Base, followed by an Exception.
b. No output, and an Exception is thrown.
c. Compilation fails due to an error on line 14.
d. Compilation fails due to an error on line 16.
e. Compilation fails due to an error on line 17.
f. Base, followed by an Exception, followed by Sub.
Questão Resolvida
Dado:
11. class Base { public void foo() { System.out.print("Base "); } }
12.
13. public class Sub extends Base {
14. public void foo() throws RuntimeException {
15. super.foo();
16. if (true) throw new RuntimeException();
17. System.out.print("Sub ");
18. }
19. public static void main(String[] args) {
20. new Sub().foo();
21. }
22. }
Qual é o resultado?
a. Base, followed by an Exception.
b. No output, and an Exception is thrown.
c. Compilation fails due to an error on line 14.
d. Compilation fails due to an error on line 16.
e. Compilation fails due to an error on line 17.
f. Base, followed by an Exception, followed by Sub.
Correto
Questão
Dado:
10. class One {
11. public One hello() { return this; }
12. }
13. class Two extends One {
14. public One hello() { return this; }
15. }
16. class Three extends Two {
17. // insert method here
18. }
Quais 2 métodos que inseridos individualmente completam corretamente a classe Three? (Escolha 2)
a. public void hello() {}
b. public int hello() { return 3; }
c. public Two hello() { return this; }
d. public One hello() { return this; }
e. public Object hello() { return this; }
Questão Resolvida
Dado:
10. class One {
11. public One hello() { return this; }
12. }
13. class Two extends One {
14. public One hello() { return this; }
15. }
16. class Three extends Two {
17. // insert method here
18. }
Quais 2 métodos que inseridos individualmente completam corretamente a classe Three? (Escolha 2)
a. public void hello() {}
b. public int hello() { return 3; }
c. public Two hello() { return this; }
d. public One hello() { return this; }
e. public Object hello() { return this; }
Correto
Correto
Questão
Dado:
10. class SuperCalc {
11. protected static int multiply(int i, int j) { return i* j;}
12. }
e:
20. class SubCalc extends SuperCalc{
21. public static int multiply(int i , int j) {
22. int ans = super.multiply(j, i);
23. return ans;
24. }
25. }
e:
30. SubCalc sc = new SubCalc ();
31. System.out.println(sc.multiply(3,3));
32. System.out.println(SubCalc.multiply(4,4));
Qual é o resultado?
A. 9
16
B. The code runs with no output.
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 21.
E. Compilation fails because of an error in line 22.
F. Compilation fails because of an error in line 31.
Questão Resolvida
Dado:
10. class SuperCalc {
11. protected static int multiply(int i, int j) { return i* j;}
12. }
e:
20. class SubCalc extends SuperCalc{
21. public static int multiply(int i , int j) {
22. int ans = super.multiply(j, i);
23. return ans;
24. }
25. }
e:
30. SubCalc sc = new SubCalc ();
31. System.out.println(sc.multiply(3,3));
32. System.out.println(SubCalc.multiply(4,4));
Qual é o resultado?
A. 9
16
B. The code runs with no output.
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 21.
E. Compilation fails because of an error in line 22.
F. Compilation fails because of an error in line 31.
Correto
Questão
Dado:
1. class Super {
2. private int a;
3. protected Super(int a) { this.a = a; }
4. } ...
11. class Sub extends Super {
12. public Sub(int a) { super(a); }
13. public Sub() { this.a = 5; }
14. }
Quais 2 independentemente permitirão Sub compilar? (Escolha 2)
a. Change line 2 to: public int a;
b. Change line 2 to: protected int a;
c. Change line 13 to: public Sub() { this(5); }
d. Change line 13 to: public Sub() { super(5); }
e. Change line 13 to: public Sub() { super(a); }
Questão Ressolvida
Dado:
1. class Super {
2. private int a;
3. protected Super(int a) { this.a = a; }
4. } ...
11. class Sub extends Super {
12. public Sub(int a) { super(a); }
13. public Sub() { this.a = 5; }
14. }
Quais 2 independentemente permitirão Sub compilar? (Escolha 2)
a. Change line 2 to: public int a;
b. Change line 2 to: protected int a;
c. Change line 13 to: public Sub() { this(5); }
d. Change line 13 to: public Sub() { super(5); }
e. Change line 13 to: public Sub() { super(a); }
Correto
Correto
Questão
Dado:
10: public class Hello { 11: String greeting;
12: int value;
13. public Hello(){
14. greeting+= “ world”;
15. }
16: public Hello(int value) {
17: this.value = value;
18: greeting = "Hello";
19: super();
20: }
21: }
e:
30: Hello c = new Hello(5);
31: System.out.println(c.greeting);
Qual é o resultado?
a. Hello
b. Hello world
c. Compilation fails.
d. Hello world 5
e. The code runs with no output.
f. An exception is thrown at runtime.
Questão Resolvida
Dado:
10: public class Hello { 11: String greeting;
12: int value;
13. public Hello(){
14. greeting+= “ world”;
15. }
16: public Hello(int value) {
17: this.value = value;
18: greeting = "Hello";
19: super();
20: }
21: }
e:
30: Hello c = new Hello(5);
31: System.out.println(c.greeting);
Qual é o resultado?
a. Hello
b. Hello world
c. Compilation fails.
d. Hello world 5
e. The code runs with no output.
f. An exception is thrown at runtime.
Correto

Mais conteúdo relacionado

Mais procurados

Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...Udayan Khattry
 
TDD CrashCourse Part4: Improving Testing
TDD CrashCourse Part4: Improving TestingTDD CrashCourse Part4: Improving Testing
TDD CrashCourse Part4: Improving TestingDavid Rodenas
 
Fnt software solutions placement paper
Fnt software solutions placement paperFnt software solutions placement paper
Fnt software solutions placement paperfntsofttech
 
ES3-2020-07 Testing techniques
ES3-2020-07 Testing techniquesES3-2020-07 Testing techniques
ES3-2020-07 Testing techniquesDavid Rodenas
 
C# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewC# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewPaulo Morgado
 
12. Java Exceptions and error handling
12. Java Exceptions and error handling12. Java Exceptions and error handling
12. Java Exceptions and error handlingIntro C# Book
 
Java language fundamentals
Java language fundamentalsJava language fundamentals
Java language fundamentalsKapish Joshi
 
Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.Nishan Barot
 
20.4 Java interfaces and abstraction
20.4 Java interfaces and abstraction20.4 Java interfaces and abstraction
20.4 Java interfaces and abstractionIntro C# Book
 
Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014Raimon Ràfols
 
The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189Mahmoud Samir Fayed
 
C++ lab assignment
C++ lab assignmentC++ lab assignment
C++ lab assignmentSaket Pathak
 
Inside PyMongo - MongoNYC
Inside PyMongo - MongoNYCInside PyMongo - MongoNYC
Inside PyMongo - MongoNYCMike Dirolf
 
Csphtp1 05
Csphtp1 05Csphtp1 05
Csphtp1 05HUST
 
Minicurso de TestesOnRails
Minicurso de TestesOnRailsMinicurso de TestesOnRails
Minicurso de TestesOnRailsSEA Tecnologia
 
An other world awaits you
An other world awaits youAn other world awaits you
An other world awaits you信之 岩永
 

Mais procurados (20)

Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
 
TDD CrashCourse Part4: Improving Testing
TDD CrashCourse Part4: Improving TestingTDD CrashCourse Part4: Improving Testing
TDD CrashCourse Part4: Improving Testing
 
Fnt software solutions placement paper
Fnt software solutions placement paperFnt software solutions placement paper
Fnt software solutions placement paper
 
ES3-2020-07 Testing techniques
ES3-2020-07 Testing techniquesES3-2020-07 Testing techniques
ES3-2020-07 Testing techniques
 
C# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewC# 6.0 - April 2014 preview
C# 6.0 - April 2014 preview
 
12. Java Exceptions and error handling
12. Java Exceptions and error handling12. Java Exceptions and error handling
12. Java Exceptions and error handling
 
Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
 
Core java
Core javaCore java
Core java
 
Java language fundamentals
Java language fundamentalsJava language fundamentals
Java language fundamentals
 
Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.
 
Exceptions
ExceptionsExceptions
Exceptions
 
20.4 Java interfaces and abstraction
20.4 Java interfaces and abstraction20.4 Java interfaces and abstraction
20.4 Java interfaces and abstraction
 
Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014
 
The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189
 
C++ lab assignment
C++ lab assignmentC++ lab assignment
C++ lab assignment
 
E:\Plp 2009 2\Plp 9
E:\Plp 2009 2\Plp 9E:\Plp 2009 2\Plp 9
E:\Plp 2009 2\Plp 9
 
Inside PyMongo - MongoNYC
Inside PyMongo - MongoNYCInside PyMongo - MongoNYC
Inside PyMongo - MongoNYC
 
Csphtp1 05
Csphtp1 05Csphtp1 05
Csphtp1 05
 
Minicurso de TestesOnRails
Minicurso de TestesOnRailsMinicurso de TestesOnRails
Minicurso de TestesOnRails
 
An other world awaits you
An other world awaits youAn other world awaits you
An other world awaits you
 

Destaque (12)

7.1. procedimientos almacenados
7.1.  procedimientos almacenados7.1.  procedimientos almacenados
7.1. procedimientos almacenados
 
Ambiguty
AmbigutyAmbiguty
Ambiguty
 
computer architecture.
computer architecture.computer architecture.
computer architecture.
 
Lexical Analyzers and Parsers
Lexical Analyzers and ParsersLexical Analyzers and Parsers
Lexical Analyzers and Parsers
 
I/O Buffering
I/O BufferingI/O Buffering
I/O Buffering
 
5. spooling and buffering
5. spooling and buffering 5. spooling and buffering
5. spooling and buffering
 
Error detection recovery
Error detection recoveryError detection recovery
Error detection recovery
 
Error detection and correction
Error detection and correctionError detection and correction
Error detection and correction
 
Role-of-lexical-analysis
Role-of-lexical-analysisRole-of-lexical-analysis
Role-of-lexical-analysis
 
Input-Buffering
Input-BufferingInput-Buffering
Input-Buffering
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
 
Error Detection And Correction
Error Detection And CorrectionError Detection And Correction
Error Detection And Correction
 

Semelhante a Revisão OCPJP7 - Class Design (parte 02)

Indus Valley Partner aptitude questions and answers
Indus Valley Partner aptitude questions and answersIndus Valley Partner aptitude questions and answers
Indus Valley Partner aptitude questions and answersSushant Choudhary
 
Hybrid inheritance
Hybrid inheritanceHybrid inheritance
Hybrid inheritancezindadili
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...MaruMengesha
 
1z0 804 exam-java se 7 programmer ii
1z0 804 exam-java se 7 programmer ii1z0 804 exam-java se 7 programmer ii
1z0 804 exam-java se 7 programmer iiIsabella789
 
Technical aptitude test 2 CSE
Technical aptitude test 2 CSETechnical aptitude test 2 CSE
Technical aptitude test 2 CSESujata Regoti
 
Multiple Choice Questions for Java interfaces and exception handling
Multiple Choice Questions for Java interfaces and exception handlingMultiple Choice Questions for Java interfaces and exception handling
Multiple Choice Questions for Java interfaces and exception handlingAbishek Purushothaman
 
2 object orientation-copy
2 object orientation-copy2 object orientation-copy
2 object orientation-copyJoel Campos
 
Language fundamentals ocjp
Language fundamentals ocjpLanguage fundamentals ocjp
Language fundamentals ocjpBhavishya sharma
 
Wap to implement bitwise operators
Wap to implement bitwise operatorsWap to implement bitwise operators
Wap to implement bitwise operatorsHarleen Sodhi
 
Comp 328 final guide
Comp 328 final guideComp 328 final guide
Comp 328 final guidekrtioplal
 
[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13Chris Ohk
 

Semelhante a Revisão OCPJP7 - Class Design (parte 02) (20)

1
11
1
 
Indus Valley Partner aptitude questions and answers
Indus Valley Partner aptitude questions and answersIndus Valley Partner aptitude questions and answers
Indus Valley Partner aptitude questions and answers
 
Oop Presentation
Oop PresentationOop Presentation
Oop Presentation
 
Core java
Core javaCore java
Core java
 
Hybrid inheritance
Hybrid inheritanceHybrid inheritance
Hybrid inheritance
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
 
1z0 804 exam-java se 7 programmer ii
1z0 804 exam-java se 7 programmer ii1z0 804 exam-java se 7 programmer ii
1z0 804 exam-java se 7 programmer ii
 
Java concurrency questions and answers
Java concurrency questions and answers Java concurrency questions and answers
Java concurrency questions and answers
 
Technical aptitude test 2 CSE
Technical aptitude test 2 CSETechnical aptitude test 2 CSE
Technical aptitude test 2 CSE
 
Multiple Choice Questions for Java interfaces and exception handling
Multiple Choice Questions for Java interfaces and exception handlingMultiple Choice Questions for Java interfaces and exception handling
Multiple Choice Questions for Java interfaces and exception handling
 
2 object orientation-copy
2 object orientation-copy2 object orientation-copy
2 object orientation-copy
 
Java Quiz
Java QuizJava Quiz
Java Quiz
 
Language fundamentals ocjp
Language fundamentals ocjpLanguage fundamentals ocjp
Language fundamentals ocjp
 
Wap to implement bitwise operators
Wap to implement bitwise operatorsWap to implement bitwise operators
Wap to implement bitwise operators
 
FSOFT - Test Java Exam
FSOFT - Test Java ExamFSOFT - Test Java Exam
FSOFT - Test Java Exam
 
C# programs
C# programsC# programs
C# programs
 
Comp 328 final guide
Comp 328 final guideComp 328 final guide
Comp 328 final guide
 
T1
T1T1
T1
 
[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13[C++ Korea] Effective Modern C++ Study, Item 11 - 13
[C++ Korea] Effective Modern C++ Study, Item 11 - 13
 
Questões de Certificação SCJP
Questões de Certificação SCJPQuestões de Certificação SCJP
Questões de Certificação SCJP
 

Mais de Julio Cesar Nunes de Souza

Mais de Julio Cesar Nunes de Souza (7)

Introdução AngularJS 4 com CLI
Introdução AngularJS 4 com CLIIntrodução AngularJS 4 com CLI
Introdução AngularJS 4 com CLI
 
Visão geral sobre Assertivas e Exceções no Java7
Visão geral sobre Assertivas e Exceções no Java7Visão geral sobre Assertivas e Exceções no Java7
Visão geral sobre Assertivas e Exceções no Java7
 
"Mas eu não tenho experiência..." E daí??? - Como quebrar o ciclo vicioso de...
 "Mas eu não tenho experiência..." E daí??? - Como quebrar o ciclo vicioso de... "Mas eu não tenho experiência..." E daí??? - Como quebrar o ciclo vicioso de...
"Mas eu não tenho experiência..." E daí??? - Como quebrar o ciclo vicioso de...
 
Revisao OCPJP - Princípios OO
Revisao OCPJP - Princípios OORevisao OCPJP - Princípios OO
Revisao OCPJP - Princípios OO
 
Revisão OCPJP7 - String Processing
Revisão OCPJP7 - String ProcessingRevisão OCPJP7 - String Processing
Revisão OCPJP7 - String Processing
 
Revisão OCPJP7 - Class Design (parte 04)
Revisão OCPJP7 - Class Design (parte 04)Revisão OCPJP7 - Class Design (parte 04)
Revisão OCPJP7 - Class Design (parte 04)
 
Revisão OCPJP7 - Class Design (parte 01)
Revisão OCPJP7 - Class Design (parte 01)Revisão OCPJP7 - Class Design (parte 01)
Revisão OCPJP7 - Class Design (parte 01)
 

Último

Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Anthony Dahanne
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
SoftTeco - Software Development Company Profile
SoftTeco - Software Development Company ProfileSoftTeco - Software Development Company Profile
SoftTeco - Software Development Company Profileakrivarotava
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024VictoriaMetrics
 

Último (20)

Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
SoftTeco - Software Development Company Profile
SoftTeco - Software Development Company ProfileSoftTeco - Software Development Company Profile
SoftTeco - Software Development Company Profile
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024
 

Revisão OCPJP7 - Class Design (parte 02)

  • 2. Questão Dado: 1. public class base { 2. protected int blipvert(int x) { return 333; } 3. } 4. class sub extends base { 5. // insert code here 6. } Quais 5 métodos inseridos independentemente na linha 5 irão compilar? (Escolha 5) a. public int blipvert(int x) { return 0; } b. private int blipvert(int x) { return 0; } c. private int blipvert(long x) { return 0; } d. protected long blipvert(int x) { return 0; } e. protected int blipvert(long x) { return 0; } f. protected long blipvert(long x) { return 0; } g. protected long blipvert(int x, int y) { return 0; }
  • 3. Questão Resolvida Dado: 1. public class base { 2. protected int blipvert(int x) { return 333; } 3. } 4. class sub extends base { 5. // insert code here 6. } Quais 5 métodos inseridos independentemente na linha 5 irão compilar? (Escolha 5) a. public int blipvert(int x) { return 0; } b. private int blipvert(int x) { return 0; } c. private int blipvert(long x) { return 0; } d. protected long blipvert(int x) { return 0; } e. protected int blipvert(long x) { return 0; } f. protected long blipvert(long x) { return 0; } g. protected long blipvert(int x, int y) { return 0; } Correto Correto Correto Correto Correto
  • 4. Questão Dado: 10. class Base { 11. void foo() { } 12. } 13. class Sub extends Base { 14. //insert method here 15. } Quais 3 métodos, inseridos individualmente na linha 14 completarão corretamente a classe Sub (Escolha 3) A. int foo() { /* more code here */ } B. void foo() { /* more code here */ } C. public void foo() { /* more code here */ } D. private void foo() { /* more code here */ } E. protected void foo() { /* more code here */ }
  • 5. Questão Resolvida Dado: 10. class Base { 11. void foo() { } 12. } 13. class Sub extends Base { 14. //insert method here 15. } Quais 3 métodos, inseridos individualmente na linha 14 completarão corretamente a classe Sub (Escolha 3) A. int foo() { /* more code here */ } B. void foo() { /* more code here */ } C. public void foo() { /* more code here */ } D. private void foo() { /* more code here */ } E. protected void foo() { /* more code here */ } Correto Correto Correto
  • 6. Questão 11. class Foo{ 12. public void process() { System.out.print("foo"); } 13. class Bar extends Foo { 14. public void process() throws IOException 15. { 16. System.out.print("Class bar"); 17. throw new IOException(); 18. } 19. public static void main(String[] args) { 20. try { new Bar().process(); } 21. catch (IOException e) { System.out.println("Not able to compete your request."); } 22. } Qual é o resultado? a. Exception b. A,B,Exception c. Compilation fails because of an error in line 20. d. Compilation fails because of an error in line 14. e. A NullPointerException is thrown at runtime.
  • 7. Questão Resolvida 11. class Foo{ 12. public void process() { System.out.print("foo"); } 13. class Bar extends Foo { 14. public void process() throws IOException 15. { 16. System.out.print("Class bar"); 17. throw new IOException(); 18. } 19. public static void main(String[] args) { 20. try { new Bar().process(); } 21. catch (IOException e) { System.out.println("Not able to compete your request."); } 22. } Qual é o resultado? a. Exception b. A,B,Exception c. Compilation fails because of an error in line 20. d. Compilation fails because of an error in line 14. e. A NullPointerException is thrown at runtime. Correto
  • 8. Questão Dado: 1. class BasePizza { 2. java.util.ArrayList toppings; 3. public final void addTopping(String topping) { 4. toppings.add(topping); 5. } 6. } 7. public class PepperoniPizza extends BasePizza { 8. public void addTopping(String topping) { 9. System.out.println("Toppings not available"); 10. } 11. public static void main(String[] args) { 12. BasePizza pizza = new PepperoniPizza(); 13. pizza.addTopping("Mushrooms"); 14. } 15. } Qual é o resultado? a. Compilation fails. b. Toppings not available. c. The code runs with no output. d. A NullPointerException is thrown in Line 4.
  • 9. Questão Resolvida Dado: 1. class BasePizza { 2. java.util.ArrayList toppings; 3. public final void addTopping(String topping) { 4. toppings.add(topping); 5. } 6. } 7. public class PepperoniPizza extends BasePizza { 8. public void addTopping(String topping) { 9. System.out.println("Toppings not available"); 10. } 11. public static void main(String[] args) { 12. BasePizza pizza = new PepperoniPizza(); 13. pizza.addTopping("Mushrooms"); 14. } 15. } Qual é o resultado? a. Compilation fails. b. Toppings not available. c. The code runs with no output. d. A NullPointerException is thrown in Line 4. Correto
  • 10. Questão Dado: 11. static class Foo { 12. void process() throws Exception { 13. System.out.println("Foo"); 14. throw new Exception(); } 15. } 16. static class Bar extends Foo { 17. void process() { System.out.println("Bar"); } 18. } 19. public static void main(String[ ] args) { 20. new Bar().process(); 21. } Qual é o resultado? A. Bar B. The code runs with no output. C. Compilation fails because of an error in line 12. D. Compilation fails because of an error in line 15 E. Compilation fails because of an error in line 18.
  • 11. Questão Resolvida Dado: 11. static class Foo { 12. void process() throws Exception { 13. System.out.println("Foo"); 14. throw new Exception(); } 15. } 16. static class Bar extends Foo { 17. void process() { System.out.println("Bar"); } 18. } 19. public static void main(String[ ] args) { 20. new Bar().process(); 21. } Qual é o resultado? A. Bar B. The code runs with no output. C. Compilation fails because of an error in line 12. D. Compilation fails because of an error in line 15 E. Compilation fails because of an error in line 18. Correto
  • 12. Questão Dado: 11. class Base { public void foo() { System.out.print("Base "); } } 12. 13. public class Sub extends Base { 14. public void foo() throws RuntimeException { 15. super.foo(); 16. if (true) throw new RuntimeException(); 17. System.out.print("Sub "); 18. } 19. public static void main(String[] args) { 20. new Sub().foo(); 21. } 22. } Qual é o resultado? a. Base, followed by an Exception. b. No output, and an Exception is thrown. c. Compilation fails due to an error on line 14. d. Compilation fails due to an error on line 16. e. Compilation fails due to an error on line 17. f. Base, followed by an Exception, followed by Sub.
  • 13. Questão Resolvida Dado: 11. class Base { public void foo() { System.out.print("Base "); } } 12. 13. public class Sub extends Base { 14. public void foo() throws RuntimeException { 15. super.foo(); 16. if (true) throw new RuntimeException(); 17. System.out.print("Sub "); 18. } 19. public static void main(String[] args) { 20. new Sub().foo(); 21. } 22. } Qual é o resultado? a. Base, followed by an Exception. b. No output, and an Exception is thrown. c. Compilation fails due to an error on line 14. d. Compilation fails due to an error on line 16. e. Compilation fails due to an error on line 17. f. Base, followed by an Exception, followed by Sub. Correto
  • 14. Questão Dado: 10. class One { 11. public One hello() { return this; } 12. } 13. class Two extends One { 14. public One hello() { return this; } 15. } 16. class Three extends Two { 17. // insert method here 18. } Quais 2 métodos que inseridos individualmente completam corretamente a classe Three? (Escolha 2) a. public void hello() {} b. public int hello() { return 3; } c. public Two hello() { return this; } d. public One hello() { return this; } e. public Object hello() { return this; }
  • 15. Questão Resolvida Dado: 10. class One { 11. public One hello() { return this; } 12. } 13. class Two extends One { 14. public One hello() { return this; } 15. } 16. class Three extends Two { 17. // insert method here 18. } Quais 2 métodos que inseridos individualmente completam corretamente a classe Three? (Escolha 2) a. public void hello() {} b. public int hello() { return 3; } c. public Two hello() { return this; } d. public One hello() { return this; } e. public Object hello() { return this; } Correto Correto
  • 16. Questão Dado: 10. class SuperCalc { 11. protected static int multiply(int i, int j) { return i* j;} 12. } e: 20. class SubCalc extends SuperCalc{ 21. public static int multiply(int i , int j) { 22. int ans = super.multiply(j, i); 23. return ans; 24. } 25. } e: 30. SubCalc sc = new SubCalc (); 31. System.out.println(sc.multiply(3,3)); 32. System.out.println(SubCalc.multiply(4,4)); Qual é o resultado? A. 9 16 B. The code runs with no output. C. An exception is thrown at runtime. D. Compilation fails because of an error in line 21. E. Compilation fails because of an error in line 22. F. Compilation fails because of an error in line 31.
  • 17. Questão Resolvida Dado: 10. class SuperCalc { 11. protected static int multiply(int i, int j) { return i* j;} 12. } e: 20. class SubCalc extends SuperCalc{ 21. public static int multiply(int i , int j) { 22. int ans = super.multiply(j, i); 23. return ans; 24. } 25. } e: 30. SubCalc sc = new SubCalc (); 31. System.out.println(sc.multiply(3,3)); 32. System.out.println(SubCalc.multiply(4,4)); Qual é o resultado? A. 9 16 B. The code runs with no output. C. An exception is thrown at runtime. D. Compilation fails because of an error in line 21. E. Compilation fails because of an error in line 22. F. Compilation fails because of an error in line 31. Correto
  • 18. Questão Dado: 1. class Super { 2. private int a; 3. protected Super(int a) { this.a = a; } 4. } ... 11. class Sub extends Super { 12. public Sub(int a) { super(a); } 13. public Sub() { this.a = 5; } 14. } Quais 2 independentemente permitirão Sub compilar? (Escolha 2) a. Change line 2 to: public int a; b. Change line 2 to: protected int a; c. Change line 13 to: public Sub() { this(5); } d. Change line 13 to: public Sub() { super(5); } e. Change line 13 to: public Sub() { super(a); }
  • 19. Questão Ressolvida Dado: 1. class Super { 2. private int a; 3. protected Super(int a) { this.a = a; } 4. } ... 11. class Sub extends Super { 12. public Sub(int a) { super(a); } 13. public Sub() { this.a = 5; } 14. } Quais 2 independentemente permitirão Sub compilar? (Escolha 2) a. Change line 2 to: public int a; b. Change line 2 to: protected int a; c. Change line 13 to: public Sub() { this(5); } d. Change line 13 to: public Sub() { super(5); } e. Change line 13 to: public Sub() { super(a); } Correto Correto
  • 20. Questão Dado: 10: public class Hello { 11: String greeting; 12: int value; 13. public Hello(){ 14. greeting+= “ world”; 15. } 16: public Hello(int value) { 17: this.value = value; 18: greeting = "Hello"; 19: super(); 20: } 21: } e: 30: Hello c = new Hello(5); 31: System.out.println(c.greeting); Qual é o resultado? a. Hello b. Hello world c. Compilation fails. d. Hello world 5 e. The code runs with no output. f. An exception is thrown at runtime.
  • 21. Questão Resolvida Dado: 10: public class Hello { 11: String greeting; 12: int value; 13. public Hello(){ 14. greeting+= “ world”; 15. } 16: public Hello(int value) { 17: this.value = value; 18: greeting = "Hello"; 19: super(); 20: } 21: } e: 30: Hello c = new Hello(5); 31: System.out.println(c.greeting); Qual é o resultado? a. Hello b. Hello world c. Compilation fails. d. Hello world 5 e. The code runs with no output. f. An exception is thrown at runtime. Correto