Twist in the Tale 1.3

Let’s modify the code of classes Book and CourseBook and define multiple combinations of static and nonstatic method print() in both these classes as follows:

a  class Book{
       static void print(){}
   }
   class CourseBook extends Book{
       static void print(){}
   }
b  class Book{
       static void print(){}
   }
   class CourseBook extends Book{
       void print(){}
   }
c  class Book{
       void print(){}
   }
   class CourseBook extends Book{
       static void print(){}
   }
d  class Book{
       void print(){}
   }
   class CourseBook extends Book{
       void print(){}
   }

Your task is to first tag them with one of the options and then compile them on your system to see if they’re correct. On the actual exam, you’ll need to verify (without a compiler) if a code snippet compiles or not:

  • Overridden ...

Get OCP Java SE 7 Programmer II Certification Guide: Prepare for the 1ZO-804 exam now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.