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

What is phantom memory?

888


What is the purpose of jdk?

836


What is jdk jre and jvm?

935


Do I really have to type in the programs in the book to try them out?

956


What is entitymanager in java?

914


Who created eclipse?

887


What is a cookie in java?

888


What is an interceptor in java?

788


What is explicit casting?

904


What is the use of lambda functions?

880


Write a program using call by refernce for two different classes to explain to print whether a given number is automorphic or not.

1826


What is @qualifier in java?

912


Do I need jdk or jre?

813


Why is javac not recognized?

821


What is the use of flatmap in java 8?

798