Selenium Class 6 Java Program Structure
Selenium Class 6 Java Program Structure
Selenium Class 6 Java Program Structure
com)
1) Documentation Section
> It includes the comments to tell the program's purpose, it improves the
readability of the program
2) Package Statement
3) Import Statement/s
Ex:
import java.io.Console;
java - Project
io - Package
Console - Class
import java.io.*;
java - Project
io - Package
io.* - import all classes from io package
--------------------------------------------
Predefined/Built-in,
All libraries in Java are predefined, but a few libraries only automatically
loaded in every Java program.
4) Class Definition
Ex:
public class Sample{
.
}
5) Interface Section
It includes method declaration
(String [] args) -?
------------------------------------------
7) Declaration Statement/s
int a;
a=100;
int b=200;
b=300;
c=400;
int a;//Correct
a=10;
a=30;
int b=200;
b=400;
-------------
final int x; //Incorrect
Conditions,
Loops,
Methods, etc...
--------------------------------
10) Object Creation Statement
Syntax:
ClassName objectName= new ClassClassName();
----------------------------------------
if (x>y){
System.out.println("X is a Big Number");
}
else{
System.out.println("Y is a Big Number");
}
}
//Create a Method with Arguments and return a value (Static method)
public static int sub(int a, int b){
int result=a-b;
return result;
}
//Create a Method without and returns nothing (Static method)
public static void comparision2(){
int a=100, b=200;
if (a>b){
System.out.println("A is a Big Number");
}
else{
System.out.println("B is a Big Number");
}
}
public static void main (String [] args){
//Create Object to call Non Static methods
Sample obj = new Sample();
int res = obj.add(100, 200);
System.out.println(res);//300
//Or
System.out.println(obj.add(100, 200));//300
//Or
System.out.println(Sample.sub(200, 100));//100
System.out.println(sub(20,10));//10
double l=123.45678;
char m='*';
boolean p=true;
String q="Selenium Testing";
System.out.println(q);//Selenium Testing
System.out.println(l);//123.45678
System.out.println("Hello Java");
if (a>b){
System.out.println("A is a Big Number");
}
else
{
System.out.println("B is a Big Number");
}
default:
System.out.println("Invalid Grade");
}
}
}
}
---------------------------------------------------------