• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Anonymous Inner Class

 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
line 1: The parent class Mammal is defined.
line 2: The abstract class Human is defined.
line 3: The anonymous inner class begins on line 3.
line 4: Contains the implementation of the abstract method.
line 5: The reference created on line 3 is used to call the method that has been implemented.



Question 1: Does the anonymous inner class begin on line 3?

Question 2:
Is a characteristic of the anonymous inner class the following :
A reference created outside of the class is used to invoke a method of the inner class?



 
Sheriff
Posts: 11606
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are inner classes not on the OCPJP7 exam instead of OCAJP7

Thomas Hauck wrote:Does the anonymous inner class begin on line 3?


Yes.


Thomas Hauck wrote:Is a characteristic of the anonymous inner class the following :
A reference created outside of the class is used to invoke a method of the inner class?


If you have a reference variable which refers to an anonymous inner class object, you can only invoke the methods which are defined by the type of the reference variable.

A few examples to illustrate:
  • If you change the type of variable h1 to Mammal line 5 will give a compiler error (The method move() is undefined for the type Mammal
  • If you would add a public method eat() to the anonymous inner class (e.g. between line 3 and 4 or before the line with };), it will be impossible to invoke this method using the reference variable h1 (because it's not defined in Human, the type of the variable). It is however possible to invoke the eat() method from within the move() method.


  • I don't know if this answers your question...
     
    Thomas Hauck
    Ranch Hand
    Posts: 106
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Roel,

    Inner classes are tested in exam 1Z0-804,
    but some candidates have said that they have seen questions with respect to inner classes on 1Z0-803.

    I just want a high level understanding of this topic in case a question is asked.

    I have made your suggested changes below.

     
    Roel De Nijs
    Sheriff
    Posts: 11606
    178
    Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Thomas Hauck wrote:Inner classes are tested in exam 1Z0-804,
    but some candidates have said that they have seen questions with respect to inner classes on 1Z0-803.


    Can you give some reference of this statement? According to this blog article (from Oracle Education): There should not be any questions on the exam that are not addressed in the exam topics.

     
    Thomas Hauck
    Ranch Hand
    Posts: 106
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    This link
    https://blogs.oracle.com/certification/entry/0620a contains

    several videos.

    For the links at the bottom

    1. Certification Track: Oracle Certified Associate (OCA) - Java SE 7 Programmer
    2. Certification Track: Oracle Certified Professional (OCP) - Java SE 7 Programmer
    3. Certification Exam: Java SE 7 Programmer I (1Z0-803)
    4. Certification Exam: Java SE 7 Programmer II (1Z0-804)
    5. Certification Exam: Upgrade to Java SE 7 Programmer (1Z0-805)
    6. Register Now: Pearson VUE


    When I click on the 3rd link down I go to

    http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=5001&get_params=p_exam_id:1Z0-803&p_org_id=&lang=

    which is a registration page.
    ----
    I have read in the book from Mala Gupta

    OCA Java SE 7

    that "Inner Classes" are not covered on the exam.
    I have also read that "try-with-resources" are not covered on the (1Z0-803).

    Different testing companies (Whizlabs and Enthuware)
    pose different questions independent of the testing outline from Oracle.

    For example:
    1) Whizlabs Test Questions have questions on
    a) try-with-resources b) Catching Multiple Exception Types
    http://docs.oracle.com/javase/7/docs/technotes/guides/language/catch-multiple.html

    2) Enthuware Test Questions have questions on
    a) Inner Classes

    Enthuware authors have said in their test explanations that testers have received questions with regards to "Inner Classes".

    Both of the examples listed above may be outside the scope of the testing outline for 1Z0-803.
    I understand for the "OCA forum" it is beneficial for the participants if the subject matter is streamlined based on the test outline from Oracle.

    Should questions on
    1) try-with-resources
    2) Catching Multiple Exception Types
    3) Inner Classes

    be posted to the forum OCP JP7 1Z0-804 forum?

    That would be a good recommendation so that the OCA forum does not become
    diluted with "test topics" that may not appear on the actual exam.

     
    Roel De Nijs
    Sheriff
    Posts: 11606
    178
    Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Thomas Hauck wrote:Should questions on
    1) try-with-resources
    2) Catching Multiple Exception Types
    3) Inner Classes

    be posted to the forum OCP JP7 1Z0-804 forum?


    None of these topics appear in the exam topics list of OCAJP7, but they do appear on the exam topics list of the OCPJP7 (inner classes mentioned as nested classes). It seems reasonable to post questions on these topics only in the OCPJP forum.

    (that's why I moved this topic to the OCPJP forum)
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic