aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Quiz 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 "Quiz" Watch "Quiz" New topic
Author

Quiz

Doit
Ranch Hand

Joined: Aug 03, 2000
Posts: 169
Question 8.
A String Class
1.is final
2.is public
3.is serializable
4.has a constructor which takes a StingBuffer Object as an Argument
I think ans is 1,2,3. But answer given also includes 4???

Question 9.

public interface AQuestion
{
void someMethod();
}
The class which implements AQuestion
1.Should have someMethod which must necessarily be public.
2.Should have someMethod which could be "friendly" or public
3.Should have someMethod which should not throw any checked exceptions.
4.Should have someMethod which cannot be sychronized as sychronized is not in the signature of the interface defination
i think answer is only 3, but answer given also includes 1???
Please correct me if i am wrong.
- Thanks
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Hi;
JSK 1.3 documentation does have a constructor for String that uses a StringBuffer:

String(StringBuffer buffer)
Allocates a new string that contains the sequence of characters currently contained in the string buffer argument.

So it does look as if all four responses are right.
If you try to compile a class that implements the AQuestion interface that declares someMethod() as:
<pre>
void someMethod(){
System.out.println("I'm public");
}
</pre>
You get a compile error:

AnswerQuestion.java:1: someMethod() in AnswerQuestion cannot implement someMethod() in AQuestion; attempting to assign weaker access privileges; was public public class AnswerQuestion implements AQuestion{
^
1 error

No access modifier would mean the method would only have package access which is weaker than public access. Believe there's a rule that states you cannot implement an Interface method with weaker access than the original.
You have to declare it as:
<pre>
public void someMethod(){}
</pre>
Hope that helps.


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
Doit
Ranch Hand

Joined: Aug 03, 2000
Posts: 169
Thanks.
Sorry i missed here the point all classes in an Interface are
public and abstract!
- Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Quiz