Java quick reference – Java is object oriented(OOP) programming language. It is platform independent and can be run on any Operating system (OS) and it requires java interpreter (for bytecode to machine code transfer) in the system.
Java applets are one type of java program which is used within a web page however JSP is used to create web applications like PHP, ASP, JSP for the purpose of creating dynamic web pages. JavaBeans is like VB and it is reusable component and the purpose is to create advanced applications. J2EE is another Java program mainly used for data transfer e.g XML structured data.
Java Object:
Java object is a real world representation with its different state & behavior
Java Class:
Class is representation of objects or it is a template for objects.
Class has data members(attributes) and methods
Java constructors:
Java constructors are for initializing the objects of a class. Constructor name is same as class name and Constructors are invoked when objects are created. every class needs constructor and if we did not create one then the compiler will create default constructor. Java modifiers are not allowed for constructors. constructors cannot return values.
e.g. for parameterized constructor
class abc
{
public abc(int numb, String strval)
{
System.out.println(“abc is a parameterized constructor of class abc”);
}
}
e.g. for default constructor
class abc
{
public abc()
{
System.out.println(“abc is a default constructor of class abc”);
}
}
Java packages:
Java packages are group of similar classes or interfaces. Java packages are kind of containers for java classes.
Accessing a package is done by a) import package.*; or b) import package.classname; etc
compile java files by “javac -d filename.java”
What is the difference between Web Layer (Presentation Tier) vs Application Layer (Logic Tier) vs Database Layer (Data Tier)
1. Presentation Layer is the interface to outside world e.g. web site.
2. Application Layer is a framework to create the interface to the Web site or Presentation Tier
3. Database Layer is the database and associated logic needed to query details.
Web Layer (Presentation Tier)
Contains Virtual Machines and Physical Machines with OS can be Windows, UNIX or Linux
Contains Apache web Server, Apache tomcat, Sun Java Web Server or MS Internet Information Services (IIS)
Application Layer (Logic Tier)
Contains Virtual Machines and Physical Machines with OS can be Windows, UNIX or Linux
Contains Apache tomcat, Red Hat JBoss, BEA Web Logic or IBM WebSphere app server
Database Layer (Data Tier)
Contains Virtual Machines and Physical Machines with OS can be Windows, UNIX or Linux
Contains SQL or Oracle
String reverse using java script split method
var splitString = str.split(“”);// Use the reverse() method to reverse the array
var arrayReverse = splitString.reverse(); // equals to [“e”, “m”, “o”, “c”, “l”, “e”, “w”]// Use join() method to join the elements of the array into a string as below in comments
var joinArray = arrayReverse .join(“”); // [“e”, “m”, “o”, “c”, “l”, “e”, “w”] to “emoclew”//Return the reversed string
return joinArray; // “emoclew”
}
stringRev(‘welcome’);
Java quick reference
Java is object oriented(OOP) programming language. It is platform independent and can be run on any Operating system (OS) and it requires java interpreter (for bytecode to machine code transfer) in the system.
Java applets are one type of java program which is used within a web page however JSP is used to create web applications like PHP, ASP, JSP for the purpose of creating dynamic web pages. JavaBeans is like VB and it is reusable component and the purpose is to create advanced applications. J2EE is another Java program mainly used for data transfer e.g XML structured data.
Java Object:
Java object is a real world representation with its different state & behavior
Java Class:
Class is representation of objects or it is a template for objects.
Class has data members(attributes) and methods
Java constructors:
Java constructors are for initializing the objects of a class. Constructor name is same as class name and Constructors are invoked when objects are created. every class needs constructor and if we did not create one then the compiler will create default constructor. Java modifiers are not allowed for constructors. constructors cannot return values.
e.g. for parameterized constructor
class abc
{
public abc(int numb, String strval)
{
System.out.println(“abc is a parameterized constructor of class abc”);
}
}
e.g. for default constructor
class abc
{
public abc()
{
System.out.println(“abc is a default constructor of class abc”);
}
}
Java packages:
Java packages are group of similar classes or interfaces. Java packages are kind of containers for java classes.
Accessing a package is done by a) import package.*; or b) import package.classname; etc
compile java files by “javac -d filename.java”
How to print alphabets using java programming:
First Method:
char cAlpha = ‘A’;
do {
System.out.println(cAlpha );
cAlpha ++;
} while (cAlpha <= ‘Z’);
Second method :
char cAlpha = ‘a’;
while (cAlpha <= ‘z’) {
System.out.println(cAlpha);
cAlpha ++;
}
Third Method :
class PrintAlphabets
{
public static void main(String args[])
{
char chAlpha;
for( chAlpha= ‘a’ ; chAlpha<= ‘z’ ; chAlpha++ )
System.out.println(chAlpha);
}
}