• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

problem with interfaces

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From khalid's mock exam
Given:-
interface I{
void setValue(int val);
int getValue();
}
Definition a:
abstract class C implements I{
int getValue(){return 0;}
abstract vid increment();
}

Can we create class c using interface I
I feel we can create because class c is defined abstract.
Am I right
 
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no you can't create instance of an abstract class
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chaitaili,
The example will fail because Interface methods are implicitly public.
Class C is providing only package access for <code>int getValue()</code>. Overriding methods cannot have lower access privileges than the original method.
Hope that helps.
------------------
Jane Griscti
Sun Certified Java 2 Programmer
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi r u a mumbaite
we r making a forum for mumbaites those preparing for scjp.
so that we can exchange notes,codes,and our experience.
check out the topic by me titled "anyone planning to appear for scjp in march"
regds
nav
 
Chaitali Deshpande
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Val Dra and thanks for ur explanation Jane
chaitali
 
If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic