Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Possible errata in OCP Study Guide Exam 1ZO-809, P. 548 Chapter 1 #12

 
Greenhorn
Posts: 4
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Second sentence perhaps should be: “Since IE is not a superclass of Firefox, this throws ClassCastException” (i.e. not subclass), because if IE were a subclass of Firefox -  it would throw ClassCastExcetion. But if IE were a superclass of Firefox and subclass of Browser  - e.go() would print out “Inside Firefox” and no Exception would be thrown:

public class Browsers {
static class Browser {
public void go() {
System.out.println("Inside Browser");
}
}
static class IE extends Browser {
public void go() {
System.out.println("Inside IE");
}
}
static class Firefox extends IE {
public void go() {
System.out.println("Inside Firefox");
}
}
public static void main(String[] args) {
Browser b= new Firefox();
IE e=(IE)b;
e.go();
}
}
Output: Inside Firefox

 
author & internet detective
Posts: 39959
804
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That sentence should go away entirely. It's misleading.
 
    Bookmark Topic Watch Topic
  • New Topic