Name: Aditi Shah
PRN: 211101177
• Input:-
Java Practical 01:Part 1
import java.util.Scanner;
public class main{
public static void main (String[] args)
Scanner a1=new Scanner(System.in);
System.out.println("Program to print Taken from user");
System.out.print("Enter a String:");
String name = a1.nextLine();
System.out.println("The String is:" +name);
• Output:-
Program to print Taken from user
Enter a String: Hi, I am a Rcpitian
The String is: Hi, I am a Rcpitian
Java Practical 01:Part 2
import java.util.Scanner;
public class Main{
public static void main(String args[]){
Scanner myobj = new Scanner(System.in);
System.out.println ("Program to accept various Input");
Name: Aditi Shah
PRN: 211101177
System.out.print ("Please enter your name: ");
String name = myobj.nextLine();
System.out.println ("You entered string: " + name);
System.out.print ("Please enter your age:");
int age = myobj.nextInt();
System.out.println ("You entered integer: " + age);
System.out.print ("Please enter your percentage: ");
float percentage = myobj.nextFloat();
System.out.println ("You entered float: " + percentage);
• Output:-
Program to accept various Input
Please enter your name: Aditi
You entered string: Aditi
Please enter your age:18
You entered integer: 18
Please enter your percentage:90
You entered float: 90.0000
Name: Aditi Shah
PRN: 211101177
Java Practical 01:Part 3
//Right Shift Operator
public class main
public static void main(String[] args)
int a = 40 ;
int b = -40 ;
int c = 0 ;
System.out.println("For First Variable");
System.out.println("40 ="+Integer.toBinaryString(a));
c=a>>2;
System.out.println("40>>2 ="+Integer.toBinaryString(c));
System.out.println("40>>>2 ="+Integer.toBinaryString(c));
System.out.println("For Second Variable");
System.out.println("-40 ="+Integer.toBinaryString(b));
c=b>>2;
System.out.println("40>>2 ="+Integer.toBinaryString(c));
System.out.println("40>>>2 ="+Integer.toBinaryString(c));
• Output:-
Name: Aditi Shah
PRN: 211101177
For First Variable
40 =101000
40>>2 =1010
40>>>2 =1010
For Second Variable
-40 =11111111111111111111111111011000
40>>2 =11111111111111111111111111110110
40>>>2 =11111111111111111111111111110110