• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Interface??

 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


can anyone tell me the traits that get to the class when it is inside an interface??
are they public ,static (acco to answer)...also final?? (doubt)..
4 is correct coz the methods declared inside an interface are non-static..
right??
5 is wrong coz there are no static methods inside an interface right ??

please correct me??
 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1 ) We can make a class in Interface.
2 ) It is not necessary that the class is always public.
3 ) It is not necessary that the class is always static.
4 ) It is right that the class methods cannot call the methods declared in the interface because in interface all methords are only declared but no defination would be given, so as soon as you write a methord name to call the methord to call like you write m1();, you treat it as a call but the JVM treatrs it as declaration of a function and give compile time error that
" Return type required ".
5 ) Refer to point 4.
 
srikanth reddy
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so gaurav...u mean to say that only 4 is correct option...
but in mock exam it was given as 234...
any idea??
 
Gaurav Chhabras
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya you are right , answers are 2,3,4

I am sure about 2 and 4 but not of 3.

In previous reply i told you that why 4 is answer, now for option 2 i would like to say that in interface all things are by default public so the option 2 is correct.

Regarding option 3 i am not sure but i am 90% sure that in interface all things are by default static also.

That means that all things in interface are Public and Static.

Thats why the answer is -: 2,3,4

If any query then contact through the same forum.

Regards
Gaurav
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By default all the members in the interface are not static.
 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All the data members in an interface are public final static only. i.e we can access those memebers without implementing the interface. They are just like static data members defined inside a class.

The methods declared inside the interface are not static, because we can't call any methods of an interface without implementing and also the methods are abstract inside an interface. Abstract and static wont go well

Classes(like data members) inside an interface by default are static, Coz we can't instantiate an interface to instantiate the nested class inside an interface.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry completely out of topic, but just randomly discovered someone by the same name. So where u from Lakshmanan?
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
all members are public and abstract I thought
 
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I think...

methods are public abstract and constants are public final static

Correct me if am wrong..
 
Sheriff
Posts: 21759
102
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!