Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
    Bookmark Topic Watch Topic
  • New Topic

E practice exam questions for SCJP 5

 
Dibbo Khan
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Report post to moderator
I purchased the e practice exam and don't understand bits of 2 questions in the first practice exam.

QUESTION 4 Exam 1

1. interface Animal {
2. void eat();
3. }
4.
5. // insert code here
6.
7. public class HouseCat extends Feline {
8. public void eat() { }
9. }


abstract class Feline implements Animal { }
-- FIRST OF ALL WHY IS THIS A LEGAL IMPLEMENTATION OF THE interface it doesn't implement the eat() method.

Question 8 Exam 1

Given:

1. class Banana {
2. int x = 1;
3. public static void main(String [] args) {
4. int x = 2;
5. Banana b = new Banana();
6. b.go();
7. }
8. { x += x; }
9. void go() {
10. ++x;
11. System.out.println(x);
12. }
13. }


Whis is the { x += x; } part of this code snippet legal???
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
Closing this thread. It is a duplicate. Please refrain from duplicate postings.

Thanks

Mark
 
    Bookmark Topic Watch Topic
  • New Topic