new ClassName(); This expression creates object in heap area and returns that obj address Here JVM creates object but JVM does not returns object original address JVM returns duplicate address, duplicate address is also called as hashcode
Correct Answer: Local class is class defined inside method EX; class A { // top level class public static void main(string[] args) { class B { // local class } } }
Correct Answer: Non-static member class is a class defined inside outer class with out static modifier EX: class A { // top level class or outer class class B { //non-static member class } }
Correct Answer: Static member class is a class defined inside outer class with static modifier EX: Class A { //top level class or outer class static class B { //static member class } }
Correct Answer: This is a keyword and used as reference to Current object address in java It means by using which object the method is called that object hashcode is stored inside the 'this'
9. When this. non-static datamember is compulsory inside non-static method
Correct Answer: Whenever there is local- variable/parameter inside the method with same name as data member Ex: Class Sample { int a; void show() { int a=5; systemoutprintln(a); // 5 systemoutprintln(thisa);//23 } } class MainApp { Public static void main(String[] args) { Sample s = new Sample(); sa = 23; sshow(); } }
10. What is the differnce among public, protected and package access data?
Correct Answer: If we are not using packages and if we are not using inheritance then there is no difference among public, protected and package access data