Created
November 2, 2012 09:04
-
-
Save sourcebits-anshul/3999618 to your computer and use it in GitHub Desktop.
// Demo class which the super class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.source; | |
public class Demo { | |
// variables that belongs to the class | |
private int a; | |
public int b; | |
protected int c; | |
int d; | |
/* no arguement constructor*/ | |
public Demo() { | |
System.out.println("This is a public demo constructor"); | |
} | |
/* one arguement constructor which is private */ | |
private Demo( String one ){ | |
System.out.println("This is a private one argument demo constructor"); | |
} | |
private void method(){ | |
System.out.println("This is a private method"); | |
} | |
public void method1(){ | |
System.out.println("This is a public method1"); | |
} | |
protected void method2(){ | |
System.out.println("This is a protected method2"); | |
} | |
void method3(){ | |
System.out.println("This is a defualt method"); | |
} | |
// Inner classes inside Demo class | |
public static class PublicStaticInnerClassOfDemo{ | |
public void InnerMethod(){ | |
System.out.println("public static class *Hi I am inside an innerMethod which is public"); | |
} | |
public static void staticInnerMethod(){ | |
System.out.println("public static class *Hi I am inside an innerMethod which is public static "); | |
} | |
private static void staticInnerMethodPrivate(){ | |
System.out.println("public static class *Hi I am inside an innerMethod which is private static "); | |
} | |
protected static void staticInnerMethodProtected(){ | |
System.out.println("public static class *Hi I am inside an innerMethod which is protected static"); | |
} | |
static void staticInnerMethodDefault(){ | |
System.out.println("public static class *Hi I am inside an innerMethod which is default static "); | |
} | |
} | |
protected class ProtectedInnerClassOfDemo{ | |
public void InnerMethodPublic(){ | |
System.out.println("ProtectedInnerClassOfDemo *Hi I am inside an innerMethod which is public"); | |
} | |
private void InnerMethodPrivate(){ | |
System.out.println("ProtectedInnerClassOfDemo *Hi I am inside an innerMethod which is private "); | |
} | |
protected void InnerMethodProtected(){ | |
System.out.println("ProtectedInnerClassOfDemo *Hi I am inside an innerMethod which is protected "); | |
} | |
void InnerMethodDefault(){ | |
System.out.println("ProtectedInnerClassOfDemo *Hi I am inside an innerMethod which is default "); | |
} | |
} | |
class DefaultInnerClassOfDemo{ | |
public void InnerMethodPublic(){ | |
System.out.println("DefaultInnerClassOfDemo *Hi I am inside an innerMethod which is public"); | |
} | |
private void InnerMethodPrivate(){ | |
System.out.println("DefaultInnerClassOfDemo *Hi I am inside an innerMethod which is private "); | |
} | |
protected void InnerMethodProtected(){ | |
System.out.println("DefaultInnerClassOfDemo *Hi I am inside an innerMethod which is protected "); | |
} | |
void InnerMethodDefault(){ | |
System.out.println("DefaultInnerClassOfDemo *Hi I am inside an innerMethod which is default "); | |
} | |
} | |
private class PrivateInnerClassOfDemo{ | |
// you can't extend private inner class of Demo | |
} | |
public class PublicInnerClassOfDemo{ | |
/*The method innerMethod1 cannot be declared | |
static; static methods can only be declared in a | |
static or top level type*/ | |
// public static void innerMethod1(){} | |
public void InnerMethodPublic(){ | |
System.out.println("PublicInnerClassOfDemo *Hi I am inside an innerMethod which is public"); | |
} | |
private void InnerMethodPrivate(){ | |
System.out.println("PublicInnerClassOfDemo *Hi I am inside an innerMethod which is private "); | |
} | |
protected void InnerMethodProtected(){ | |
System.out.println("PublicInnerClassOfDemo *Hi I am inside an innerMethod which is protected "); | |
} | |
void InnerMethodDefault(){ | |
System.out.println("PublicInnerClassOfDemo *Hi I am inside an innerMethod which is default "); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment