Java-Staic Inner Class

Staic Inner Class There are two types of nested class: static and non-static. Nested class that are defined static are called static nested class. Non-static nested class are called inner class. Nested static class doesn’t need reference of Outer class. static nested class cannot access non-static data member or method. To create an object for the static Inner class, use … Read more…

Java-Inner Class Directly Access Outer Class Members

Inner class directly access Outer class Members Inner class can directly access Outer class members. But the outer class cannot directly access inner class members. Program Program Source class Outer { int outerData = 10; void outerValue() { System.out.println(“outerData = “+outerData); } void callInnerMethod() { Inner obj = new Inner(); obj.innerValue(); } class Inner { … Read more…

Java-Access Inner Class

Access Inner Class An object of Inner class cannot be created without an object of outer class. Create the inner object within the outer object with this following syntax : Program Program Source class Outer { void outerMethod() { System.out.println(“OuterMethod Called”); } class Inner { void innerMethod() { System.out.println(“InnerMethod Called”); } } } public class Javaapp { … Read more…

Java-Nested Classes

Nested Classes You can put the definition of one class inside the definition of another class, that is called nested class. It is also known as inner class. Program Program Source class Outer { class Inner { void innerMethod() { System.out.println(“InnerMethod Called”); } } void callInnerMethod() { Inner obj = new Inner(); obj.innerMethod(); } void … Read more…

Java-Default Value of Class Members

Default Value of Class Members The member variable is declared but not defined, it is always default-initialized to a zero of the appropriate. Following table shows variables types and their default values : Data Type Default value char 0 int / short / long / byte 0 float / double 0.0 String null Program Program Source class Data{ byte byt; int … Read more…

Java-Simple Class Construction

Simple Class Construction The class is nothing but a template for object you are going to create or it’s a blue print by using this we create an object. In simple word we can say it’s a specification or a pattern which we define and every object we define will follow that pattern. Here is … Read more…