// Code no-1
public class HelloWorld{
public static void main(String[] args) {
[Link]("HelloWorld");
// Code no-2
public class TempVariable {
public static void main(String[] args) {
int a =10 , b =20;
[Link]("Before Swap the value of A and B is :" +a + " & " +b);
int temp = a;
a =b;
b = temp;
[Link]("After Swap the value of A and B is :" +a + " & " +b);
// Code-no-3
public class WithOutTempVariable{
public static void main(String[] args) {
int a=5 ,b=10;
[Link]("Before swap the value of A and B is :" +a + " & " +b);
a=a+b;
b=a-b;
a=a-b;
[Link]("After the swap the value of A and B is :" +a + " & " +b);
// Code-no-4
class Student{
String name;
int age;
public void printinfo() {
[Link]([Link]);
[Link]([Link]);
public class OOP {
public static void main(String[]args) {
Student S1 =new Student();
[Link] = "Pawan Singh Rajput";
[Link] = 19;
[Link]();
}
// Code-no-5
class Student{
String name;
int age;
public void printinfo() {
[Link]([Link]);
[Link]([Link]);
public class Oop_2 {
public static void main(String[]args) {
Student S1 =new Student();
[Link] = "Pawan Singh Rajput";
[Link] = 19;
[Link]();
Student s2 =new Student();
[Link]= "Vikram Singh";
[Link]= 21;
[Link]();
}
// Code-no-6
class Employe{
String name;
int id;
public void printinfo() {
[Link]([Link]);
[Link]([Link]);
public class OOP_3 {
public static void main(String[]args) {
Employe S1 =new Employe();
[Link] = "Pawan Singh Rajput";
[Link] = 100001;
[Link]();
Employe s2 =new Employe();
[Link]= "Vikram Singh";
[Link]= 21003;
[Link]();
}
// Code-no-7
class Student{
String name;
int age;
public void printinfo(){
[Link]([Link]);
[Link]([Link]);
Student(String name ,int age) {
[Link]=name;
[Link]=age;
public class Constructor {
public static void main(String[]args){
String name;
int age;
Student s1=new Student(name="Pawan Singh",age=19);
[Link]();
}
// Code-no-8
class Student{
String name;
int age;
public void printinfo(){
[Link]([Link]);
[Link]([Link]);
Student(String name ,int age) {
[Link]=name;
[Link]=age;
public class Constructor_2 {
public static void main(String[]args){
String name;
int age;
Student s1=new Student(name="Pawan Singh",age=19);
[Link]();
Student s2=new Student(name="Vikram Singh",age=21);
[Link]();
}
// Code-n-9
class Student{
String name;
int age;
public void printinfo(){
[Link]([Link]);
[Link]([Link]);
Student(Student s2) {
[Link]=[Link];
[Link]=[Link];
Student() {
public class CopyConstructor {
public static void main(String[]args) {
String name;
int age;
Student s1=new Student();
[Link]="Pawan Singh";
[Link]=19;
[Link]();
Student s2=new Student(s1);
[Link]();
// Code-n-10
class Student{
String name;
int age;
public void printinfo(){
[Link]([Link]);
[Link]([Link]);
Student(Student s2) {
[Link]=[Link];
[Link]=[Link];
Student() {
public class CopyConstructor_2 {
public static void main(String[]args) {
String name;
int age;
Student s1=new Student();
[Link]="Pawan Singh";
[Link]=19;
[Link]();
Student s2=new Student(s1);
[Link]();
Student s3=new Student(s2);
[Link]();
Student s4=new Student(s3);
[Link]();
// Code-no-11
public class New {
public static void main(String[]args){
boolean d=true;
byte a=5;
short b=10;
char c='a';
int e=15;
float f =10.11f;
long g=1000011;
double h =100002200.123;
[Link](d);
[Link](a);
[Link](b);
[Link](c);
[Link](e);
[Link](f);
[Link](g);
[Link](h);
// Code-no-12
public class New_2 {
public static void main(String[]args){
boolean d=true;
byte a=5;
short b=10;
char c='a';
int e=15;
float f =10.11f;
long g=1000011;
double h =100002200.123;
[Link](d + "\n"+a + "\n" +b + "\n"+c +"\n"+e + "\n"+f + "\n"+g + "\n"+h +"\n");
// Code-no-13
import [Link];
public class Scan {
public static void main(String[]args) {
[Link]("Welcome to Scanner Class :");
Scanner sc=new Scanner
([Link]);
[Link]("Please Enter the value of A :");
int a =[Link]();
[Link]("Please Enter the value of B :");
int b =[Link]();
int sum = a+b;
[Link]("The Sum is :" +sum);
}
}
// Code-no-14
public class Size {
public static void main(String[] args) {
[Link]("The size of byte is : " +[Link] + " bits ");
[Link]("The size of int is : " +[Link] + " bits ");
[Link]("The size of float is : " +[Link] + " bits ");
[Link]("The size of char is : " +[Link] + " bits ");
[Link]("The size of short is : " +[Link] + " bits ");
[Link]("The size of long is : " +[Link] + " bits ");
[Link]("The size of double is : " +[Link] + " bits ");
// Code-no-15
public class SizeInBytes {
public static void main(String[] args) {
[Link]("The size of byte is : " +([Link]/8 ) +" bytes ");
[Link]("The size of int is : " +([Link]/8) + " bytes ");
[Link]("The size of float is : " +([Link])/8 + " bytes ");
[Link]("The size of char is : " +([Link]/8) + " bytes ");
[Link]("The size of short is : " +([Link]/8 )+ " bytes ");
[Link]("The size of long is : " +([Link]/8) + " bytes ");
[Link]("The size of double is : " +([Link]/8) + " bytes ");
// Code-no-16
public class Operator {
public static void main(String[] args) {
int a = 5;
[Link]("The value of A is : " +a);
// Code-no-17
public class Operator_2{
public static void main(String[] args) {
int a = 5;
int b = 10;
int sum = a+b;
[Link]("The sum of A and B is : " +sum);
}
// Code-no-18
public class Operator_3{
public static void main(String[] args) {
int a = 5;
int b = 10;
int sub = a-b;
[Link]("The sub of A and B is : " +sub);
// Code-no-19
public class Operator_4{
public static void main(String[] args) {
int a = 5;
int b = 10;
int multi = a*b;
[Link]("The mul of A and B is : " +multi);
}
// Code-no-20
public class Operator_5{
public static void main(String[] args) {
int a = 10;
int b = 5;
int div = a/b;
[Link]("The div of A and B is : " +div);
// Code-no-21
public class Operator_6{
public static void main(String[] args) {
int a = 10;
int b = 5;
int mod = a%b;
[Link]("The mod of A and B is : " +mod);
}
// Code-no-22
public class Operator_7{
public static void main(String[] args) {
int a = 10;
int b = 5;
int sum = a+b;
[Link]("The sum of A and B is : " +sum);
int sub = a-b;
[Link]("The sub of A and B is : " +sub);
int multi = a*b;
[Link]("The multi of A and B is : " +multi);
int div = a/b;
[Link]("The div of A and B is : " +div);
int mod = a%b;
[Link]("The mod of A and B is : " +mod);
// Code-no-23
public class Operator_8 {
public static void main(String[] args) {
int a= 10 , b= 20;
int sum = a+b;
int sub = a-b;
int multi = a*b;
int div = a/b;
int mod = a%b;
[Link]("The Sum is : " +sum + "The Sub is : " +sub + "The multi is : " +multi + "The div
is : " +div + "The mod is :" + mod );
// Code-no-24
public class Ternory {
public static void main(String[] args) {
int a= 10, b= 20;
String result = (a>b)? "True" : "False";
[Link](result);
// code-no-25
public c/lass Operator_9 {
public static void main(String[] args) {
int a =10 ,b= 20;
; [Link]("The sum is : " +(a+b));
[Link]("The sub is : " +(a-b));
[Link]("The multi is : " +(a*b));
[Link]("The div is : " +(a/b));
[Link]("The mod is : " +(a%b));
// Code-no-26
public class Operator_10 {
public static void main(String[] args) {
int a= 10 ,b=20;
[Link]("The sum is :" +(a+b)+"\n"+ "The sub is : "+(a-b)+"\n"+ "The multi is : "+(a*b)+"\
n"+"the div is : "+(a/b)+"\n"+ "the Mod is : "+(a%b)+"\n");
// code-no- 27
public class Operator_11 {
public static void main(String[] args) {
int a =3;
if(a%2==0)
[Link]("The number is even :");
else{
[Link]("The Number is Odd : ");