What is data encapsulation?
No Answer is Posted For this Question
Be the First to Post Answer
What is explicit casting?
How do I know if I have jre or jdk?
If one class havent the constructor, it has normal method, then can i use super keyword to call the method form the sub class and vice verse?
What is the use of lambda functions?
What about 'hostile applets'? : java security
What is the difference between Object Code and ByteCode? Why do people keep saying that bytecode is like the intermediate of source and object code? Also, which is better/commonly used and why? Please keep in mind that I am a beginner, please keep all terminology fairly simple. Thanks!
How do I export a java project?
What is java lang noclassdeffounderror?
What is the java api?
What is repository pattern in java?
What is static class in java?
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.