//RULE:we can use the final keyword with DataTypes but values of variables are not modifies later
public class Final_DataTypes
{
public void testMethod()
{
final int x=10;
System.out.println("ok");
}
}
Friday, February 25, 2011
Final_Methods
//RULE:we can use the final keyword with methods but methods are not overrides
public class Final_Methods
{
public final void testMethod()
{
final int x=10;
System.out.println("ok");
}
}
public class Final_Methods
{
public final void testMethod()
{
final int x=10;
System.out.println("ok");
}
}
Labels:
Final_Methods
Final_Interface
//RULE:we can not use the final keyword to the interface
final interface Final_Interface
{
public static void main(String ar[])
{
System.out.println("illegal combination of final and interface");
}
}
final interface Final_Interface
{
public static void main(String ar[])
{
System.out.println("illegal combination of final and interface");
}
}
Final_Class
//RULE:we can use the final keyword to a class but it doesent support inheritence concept
final class Final_Class
{
public static void main(String ar[])
{
System.out.println("ok");
}
}
final class Final_Class
{
public static void main(String ar[])
{
System.out.println("ok");
}
}
Labels:
Final_Class
Aabstract_Implements
/*
RULE:we can not implements an abstract class but extends
*/
abstract class Aabstract_Implements implements Aabstract_Class
{
public static void main(String ars[])
{
System.out.println("this example demonstate that we can not implements an abstract class");
}
}
RULE:we can not implements an abstract class but extends
*/
abstract class Aabstract_Implements implements Aabstract_Class
{
public static void main(String ars[])
{
System.out.println("this example demonstate that we can not implements an abstract class");
}
}
Aabstract_Static
/*
RULE:we can not use abstract-class as static keywords commibinations
*/
abstract static class Aabstract_Static_Class
{
public void test()
{
System.out println("modifier not allowed here");
}
}
RULE:we can not use abstract-class as static keywords commibinations
*/
abstract static class Aabstract_Static_Class
{
public void test()
{
System.out println("modifier not allowed here");
}
}
Abstract_Final
/*
RULE:we can not use the final keyword to a abstrct class
*/
final abstract class Abstract_Final
{
public static void main(String ar[])
{
System.out.println("illegal combination of final and interface");
}
}
RULE:we can not use the final keyword to a abstrct class
*/
final abstract class Abstract_Final
{
public static void main(String ar[])
{
System.out.println("illegal combination of final and interface");
}
}
Labels:
Abstract_Final
Abstract_Private_Class
/*
RULE:we can not specifies abstract as private and protected
*/
abstract private class Abstract_Private_Class
{
public void test();
}
RULE:we can not specifies abstract as private and protected
*/
abstract private class Abstract_Private_Class
{
public void test();
}
Aabstract_Public_Class
/*
RULE:-abstract may be have public access specifier
*/
abstract public class Aabstract_Public_Class
{
public void test()
{
System.out.println("allowed here combination of keywords");
}
}
RULE:-abstract may be have public access specifier
*/
abstract public class Aabstract_Public_Class
{
public void test()
{
System.out.println("allowed here combination of keywords");
}
}
abstract extends
/*
RULE: we can extend an abstract class
*/
abstract class Aabstract_Extends extends Aabstract_Class
{
public static void main(String ars[])
{
System.out.println("this example demonstate that we can extend an abstract class");
}
}
RULE: we can extend an abstract class
*/
abstract class Aabstract_Extends extends Aabstract_Class
{
public static void main(String ars[])
{
System.out.println("this example demonstate that we can extend an abstract class");
}
}
abstract-without methods
/*
RULE: an abstract class can contain without methods
*/
abstract class Aabstract_Class_No_Abstractmethods
{
}
RULE: an abstract class can contain without methods
*/
abstract class Aabstract_Class_No_Abstractmethods
{
}
abstract methods
/*
RULE: an abstract class can contain any no of methods with/without method bodys
*/
abstract class Aabstract_Class_Methods
{
int x;
int y;
abstract void myMethod1();
abstract void myMethod2();
abstract void myMethod3();
void myMethod4()
{
}
void myMethod5()
{
}
}
RULE: an abstract class can contain any no of methods with/without method bodys
*/
abstract class Aabstract_Class_Methods
{
int x;
int y;
abstract void myMethod1();
abstract void myMethod2();
abstract void myMethod3();
void myMethod4()
{
}
void myMethod5()
{
}
}
abstract variables
/*
RULE: an abstract class can contain any no of instace variables and methods
*/
abstract class Aabstract_Class_Any
{
int x;
int y;
abstract void myMethod1();
abstract void myMethod2();
abstract void myMethod3();
}
NEXT
RULE: an abstract class can contain any no of instace variables and methods
*/
abstract class Aabstract_Class_Any
{
int x;
int y;
abstract void myMethod1();
abstract void myMethod2();
abstract void myMethod3();
}
NEXT
Subscribe to:
Posts (Atom)