aspose file tools*
The moose likes Beginning Java and the fly likes Certification cx 310-035 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Certification cx 310-035" Watch "Certification cx 310-035" New topic
Author

Certification cx 310-035

Thomas Thomas
Greenhorn

Joined: Jun 17, 2003
Posts: 28
I have two questions. One i need a comments and second i need an answer.
public class Test{
static int var1=5;
public void increment(int var1){
var1= var1+this.var1;
System.out.println(var1);
}
public static void main(String[] args){
Test A = new Test();
A.increment(2);
}
}
I need a comment that with "this" reference answer is different as you all know. I am working on a static with "this" combination which sounds bad..
The second one is i am following kathys book for programmer certification ..Good one. I will say more after the exam.
package cert;
class Beverage{
}
package exam.stuff;
import cert.Beverage;
class Tea extends Beverage{
}
The question that Kathy asked was
?What do you best suggest as a access modifier for class Beverage.
Ans:Either make the class Beverage public or put both them in same package. In an Earlier instance she mentioned private and protected are not useful modifiers for the class. I could figure out "private". But why not protected in the above case?
Thanks for Effort
Thomas
Edwin Keeton
Greenhorn

Joined: Jul 22, 2002
Posts: 18
Addressing your 2nd question, a top-level class can only have default or public access. A private class would clearly be meaningless and is not allowed.
The protected keyword refers to visibility through inheritance rather than by reference. It applies to members rather than classes because you don't inherit a super class but rather the members of a super class. So protected is also not allowable as an access modifier for top-level classes.
If you could have a protected class, it would not be visible outside its package anyway, and would not be distinguishable from default access.
Kao-Wei Wan
Greenhorn

Joined: Jun 02, 2003
Posts: 7
class Test{
static int var1=5;
public static void increment(int var1){
var1= var1+Test.var1;
System.out.println(var1);
}
public static void main(String[] args){
Test.increment(2);
}
}
how about this??
Thomas Thomas
Greenhorn

Joined: Jun 17, 2003
Posts: 28
Thanks a lot
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Certification cx 310-035