Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 / madan

This piece of code will not generate an error surely even
with the dot notations. if you got errors post the
description of that error here

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How should I format my code? How should I comment my code?

954


What is flatmap in java8?

954


What do you understand by casting in java language? What are the types of casting?

847


Explain the encapsulation principle.

890


Can I have multiple main methods in the same class?

870


What is the difference between the boolean & operator and the && operator?

923


Which version of my browser should I use? : java security

924


Is php faster than java?

853


What is numberformatexception in java?

867


Can the main method be overloaded?

946


What is meant by framework in java?

991


What is type inference? Is type inference available in older versions like java 7 and before 7 or it is available only in java se 8?

894


Can we extract main method from another class?

939


What is mime in java?

881


What is an entity in java?

949