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