• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Question abou interfaces and instantiation

 
Ranch Hand
Posts: 172
1
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,


as everybody knows, interfaces cannot be instantiated. Hence it is forbidden to write



So I saw this question:



and it stated as a correct declaration the following line:

 Why it this correct??
 
author
Posts: 23907
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ioanna Katsanou wrote:
and it stated as a correct declaration the following line:

 Why it this correct??



May we ask why you think it is incorrect? What is wrong with instantiating an array to hold objects that implement the Jump interface?

Henry
 
Saloon Keeper
Posts: 13280
292
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ioanna Katsanou wrote:So I saw this question


Please cite your sources.


This is not valid Java code.

 Why it this correct??


You're not instantiating a Jump, but an array.
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:


This is not valid Java code.



In what way is that not valid?
 
Ioanna Katsanou
Ranch Hand
Posts: 172
1
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is question 48 from full mock exam from the book Mala Gupta - OCA Java SE Programmer I CertificationGuide.
 
Ioanna Katsanou
Ranch Hand
Posts: 172
1
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:
You're not instantiating a Jump, but an array.



Ok thanks !! That was the part I was confused about..

 
Ioanna Katsanou
Ranch Hand
Posts: 172
1
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dave Tolls wrote:

Stephan van Hulst wrote:


This is not valid Java code.



In what way is that not valid?



I aggre I cannot understand either why this is not valid?! I think it is ok
 
Stephan van Hulst
Saloon Keeper
Posts: 13280
292
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry, I misread and confused myself.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic