• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Errors in OCP 1Z0-815 Wiley Test Banks Bonus Exam 2

 
Ranch Hand
Posts: 185
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

For question 59, it shows the java command before the codes, so I was really confused.


Q. 59 What is the result of compiling the following code?

java _______ library.jar MainClass.class


A. The code compiles without issue.

B. The first compiler error is on line 2.

C. The first compiler error is on line 3.

D. The first compiler error is on line 5.

E. The first compiler error is on line 6.

F. The first compiler error is on line 7.

G. The code compiles but throws an exception at runtime.




For question 67, answer C is not correct. Without reading too much into the answer C, we know that multiple inheritance is not possible in Java, so answer C should be correct. According to the explanation, a class can inherit multiple classes, but this is through a chain (For example, RuntimeException -> Exception -> Throwable -> Object). Also, Exception does not inherit from Error, contrary to the explanation.


Q. 67 Which statements about inheritance are correct? (Choose all that apply.)

A. A class can extend multiple interfaces.

B. Java supports multiple inheritance of parent classes.

C. A class inherits at most one class.

D. An interface may extend multiple interfaces.

E. A class can extend multiple classes.

F. A class can implement multiple interfaces.

SOLUTIONS
D, F.

Classes do not extend interfaces, but they can implement multiple interfaces, making option A incorrect and option F correct. Java supports single inheritance of objects, making option B incorrect and option E incorrect. While Java supports single inheritance, a class can inherit multiple classes. For example, RuntimeException inherits Exception, which inherits Error, and finally Object. For this reason, option C is incorrect. An interface can extend multiple interfaces, making option D correct.




For question 74, it only has radio buttons so I can only choose one answer. But there are actually more than one answer.


Q. 74 Which of the following compile? (Choose all that apply.)

A. List<Integer> x1 = new ArrayList();

B. List<Integer> x2 = new ArrayList<>();

C. List<Integer> x3 = new ArrayList<Integer>();

D. List<> x4 = new ArrayList<Integer>();

E. List<Integer> x5 = new List<Integer>();

F. ArrayList<int> x6 = new List<int>();

 
Marshal
Posts: 67443
257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please don't copy line numbers into code tags.
Q74: Agree. And which of the options will compile with and without warnings?
Q59: Agree. C isn't correct. Please tell us which you think the correct answer is, and why.
Q67: The bit about Error is, as you suggest, a misprint; it should read Throwable. I think that question could have been worded differently. If you have something like Object→Component→JPanel, the panel inherits some members from Object and some from other superclasses. If you go through the JPanel documentation, you will find which (non‑private) members it inherits from which superclass. Ten of the eleven methods from Object, for example.
 
Edmund Yong
Ranch Hand
Posts: 185
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Please don't copy line numbers into code tags.
Q74: Agree. And which of the options will compile with and without warnings?
Q59: Agree. C isn't correct. Please tell us which you think the correct answer is, and why.
Q67: The bit about Error is, as you suggest, a misprint; it should read Throwable. I think that question could have been worded differently. If you have something like Object→Component→JPanel, the panel inherits some members from Object and some from other superclasses. If you go through the JPanel documentation, you will find which (non‑private) members it inherits from which superclass. Ten of the eleven methods from Object, for example.



The line numbers are present in the codes for question 59, so of course I have to copy it. The answers refer to the line numbers, so they are necessary.

I purposely don't put the correct answers here unless necessary, so as not to spoil it for those who have yet taken this quiz. For question 59, the problem is the extra java command, which makes the question confusing. It should not be there. I don't have to reveal the answers to this question since it is not relevant to the issue here.
 
I brought this back from the farm where they grow the tiny ads:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!