public class Dog {
private int weight;
public int getweight(){
return weight;
}
public void SetWeight(int newWeight){
if (newWeight > 0){
weight = newWeight;
}
}
}
public class TestDog {
public static void main(String[] args) {
Dog d = new Dog();
System.out.println("Dog d's weight is " + d.getWeight());
d.setWeight(42);
System.out.println("Dog d's weight is " + d.getWeight());
d.setweight(-42);
System.out.println("Dog d's weight is " + d.getWeight());
}
}
class dog is compiled but there is an error in class
TestDog when compiled and the error is with dot notations. I
want to kmow why there is error in testdog class when compiled.
Answer Posted / ashu chhabra
Thanks Aashish singh. You r right.My problem is solved
thankyou very much.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the difference between java se and java ee?
Which instutute is offering course for rhino jain slee
What is map and flatmap?
How long can a lambda function run?
What is jpa project?
What are the authentication modes in asp.net? : java security
What is factory pattern in java?
Can we write lambda without functional interface?
What is a driver in java?
Why are lambda functions called lambda?
Is jvm a compiler or an interpreter?
What is java net url?
In java what is the difference between sleep() and wait() .
What is the difference between lambda expression and anonymous methods?
What is a controller in java?