File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Interface?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Interface??" Watch "Interface??" New topic


srikanth reddy
Ranch Hand

Joined: Jul 28, 2005
Posts: 252

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..
5 is wrong coz there are no static methods inside an interface right ??

please correct me??

Thanks & Regards<br /> <br />-Srikanth
Gaurav Chhabras
Ranch Hand

Joined: Sep 21, 2005
Posts: 126
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

Joined: Jul 28, 2005
Posts: 252
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

Joined: Sep 21, 2005
Posts: 126
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.

Srikanth synt

Joined: Nov 04, 2005
Posts: 1
By default all the members in the interface are not static.
Lakshmanan Arunachalam
Ranch Hand

Joined: Nov 02, 2005
Posts: 99
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.

Regards<br />Lakshmanan<br />IBM-OOAD & UML, SCEA-I
Lakshmanan Arunachalam II

Joined: Nov 12, 2005
Posts: 1
Sorry completely out of topic, but just randomly discovered someone by the same name. So where u from Lakshmanan?
david lightman
Ranch Hand

Joined: Nov 03, 2004
Posts: 82
all members are public and abstract I thought
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 980

I think...

methods are public abstract and constants are public final static

Correct me if am wrong..
Rob Spoor

Joined: Oct 27, 2005
Posts: 20275

You are correct.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Interface??
It's not a secret anymore!