Powered By Blogger

Sunday, March 20, 2011

SCJP Naming convention and First Java Program

/**
*
*/
package com.patil.chapter1;

/**
* @author basanagowda.patil
*
*/
public class NamingConvention {

private static int $1;
private static Integer integr2;
private static double dou1ble;
private static Double $dou1$ble2;
private static float floatValue;
private static Float floatValue$;
private static boolean boolean1;
private static Boolean _boolean$;

public static void main(String[] args) {


System.out.println("static method can access only static variable or the static method");
System.out.println("Naming Convention and default value is:::"+ $1);
System.out.println("default value of double is:::"+ dou1ble);
System.out.println("default value of Integer is:::"+ integr2);
System.out.println("default value of double is:::"+ dou1ble);
System.out.println("default value of Double is:::"+ $dou1$ble2);
System.out.println("default value of float is:::"+ floatValue);
System.out.println("default value of Float is:::"+ floatValue$);
System.out.println("default value of boolean is:::"+ boolean1);
System.out.println("default value of Boolean is:::"+ _boolean$);




}

static{
System.out.println("Starting with the static block");
System.out.println("variable can be started with the number or characters,only $ is allowed as the special character");
$1 = 100;
}

NamingConvention(){
System.out.println("Inside the Constructor");
System.out.println("Constructor is not called since we have not instantiated");
}

public void nonstaticMethod(){
System.out.println("Inside nonstaticMethod");
}

public void $methodWithNumber1AndSpecial$Character(){
System.out.println("Inside nonstaticMethod");
System.out.println("Method can start only with the special character $, other characters are not allowed");
System.out.println("Method cannot start with the Number,but inbetween it can have the number");
}

public void _methodWithUnderScore1AndSpecial$Character(){
System.out.println("Method Name can be started with the underscore, and even the character can start with the underscore");

}

}

No comments:

Post a Comment