Showing posts with label class in java. Show all posts
Showing posts with label class in java. Show all posts

Friday, December 30, 2016

Use predefined class as identifiers in JAVA

E. In java application, we are able to use all predefined class names & interface names as identifiers.

EX: 1
int Exception= 10;
System.out.println(Exception);

Status: No compilation error
Output: 10

Note: Here Exception is an int variable.
---------------

EX: 2
String String = "String";
System.out.println(String);

Status: No compilation Error.
Output: String

Note: Here First String is as String class, 2nd String as a variable, 3rd String as value of variable.
--------------

EX: 3
int System = 10;
System.out.println(System);

Status: Compilation Error.
Reason: In java application , if we declare "System" as an integer variable then in the remaining program, we must use that System as integer variable only, we must not use that System as original class name, if we use "System" as original class name then compiler will rise an error.

In the above context if wi want to use System as class name, then we have to use its "fully qualified name" providing class name along their package name is called as "Fully qualified name".

EX:
class Test
{
public static void main(String[] args)
{
int System = 10;
java.lang.System.out.println(System);
System=System + 10;
java.lang.System.out.println(System);
}
}

Status: No compilation error
Output:
10
20
---------------------------

Along with the above rules & regulations, JAVA has provided the following suggestiong to use identifiers in JAVA application:

1. It is suggestible to provide identifier with a particular meaning.
EX:
String aa = "abc123"; ---------> Not Suggestible
String accNo = "abc123"; ------> Suggestible

2. In Java Application, there is no length restriction for the identifiers, but, it is suggestible to manage length of the identifier around 10 symbols.
EX: 
String temporaryemployeeaddress = "Hyd"; -------> Not Suggestible
String tempEmpAddr = "Hyd"; --------------------> Suggestible

3. If we have multiple words with in a single identifier then it is suggestible to separate multiple words with special notation like '-' symbol.
EX:
String tempEmpAddr = "Hyd"; -----> Not Suggestible
String temp_Emp_Addr = "Hyd"; ---> Suggestible

You May Also Like --> Classes Vs Interference 

Wednesday, December 21, 2016

Classes and Interface in JAVA Programming Format

Classes Or Interface Section:

-----------------------------------------------------------------------------------------------------------------------
In JAVA application, the main intention of classes and interfaces is to represent real world entities in the form of coding part.
EX: student, Employee, Customer, Account, Product...

Note: In JAVA application Entities data will be represented in the form of variables and entity behavior are represented in the form of methods.
EX:

public class Account // Entity
{
// Entities Data in the form of variables
public String acc_No;
public String acc_name;
public String acc_Type;
public long balance;
----------
----------
// Entity behaviors in the form of methods.
public void create(String acc_No, String acc_name, String acc_Type, long balance)
{

}

public void update(String acc_No, String acc_name, String acc_Type)
{

}

public void delete(String acc_No)
{

}

}

Note: In JAVA Application , we can write any no of classes and interfaces as per the application requirement.