Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
50 views

Practice Set For JAVA Operator

Uploaded by

Rakhit Mahato
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Practice Set For JAVA Operator

Uploaded by

Rakhit Mahato
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Practice set for JAVA_Operator v) public class Test {

public static void main(String[] args){


1.Using ternary operator implement the biggest among three int x = 9, y = 12;
integer. int a = 2, b = 4, c = 6;
2. Find the output of the : int exp = 4/3 * (x + 34) + 9 * (a + b * c) + (3 + y * (2 + a)) / (a +
b*y);
i)public class Test { System.out.println(exp);}}
public static void main(String[] args){
int x = 10, y = 5; vi) public class Test {
int exp1 = (y * (x / y + x / y));
public static void main(String[] args){
int exp2 = (y * x / y + y * x / y);
System.out.println(exp1);
int x = 9, y = 12;
System.out.println(exp2);}} int a = 2, b = 4;
boolean exp = 4/3 * (x + 34) < 9 * (3 + y * (2 + a)) / (a + b*y);
ii) public class Test { System.out.println(exp); }}
public static void main(String[] args){
double exp1 = (3.0 * 2 / 4); vii) public class Test {
int exp2 = (3 * -2 % 4); public static void main(String[] args) {
System.out.println(exp1); int x = 200, y = 50, z = 100;
System.out.println(exp2);}} if(x > y && y > z){
System.out.println("Hello"); }
iii) public class Test { if(z > y && z < x){
public static void main(String[] args){ System.out.println("Java"); }
int x = 9, y = 12, z = 3; if((y+200) < x && (y+150) < z){
int exp1 = x - y/3 + z * 2 - 1; System.out.println("Hello Java"); } } }
int exp2 = (x - y)/3 + ((z * 2) - 1);
System.out.println(exp1); viii) public class Test{
System.out.println(exp2); }} public static void main(String[] args) {
int x = 1, y = 2, z = 5;
iv) public class Test { if(x == 1 || x > y || x > z){
public static void main(String[] args){ System.out.println("One"); }
int x = 9, y = 12; if(x == y || y == 2 || z == 5){
int a = 2, b = 4, c = 6; System.out.println("Two"); }
int exp = (3 + 4 * x)/5 - 10 * (y - 5) * (a + b + c)/x + 9 * (4/x + (9 if(x == y || y == z || z == x) {
+ x)/y); System.out.println("Three");}}}
System.out.println(exp); }}
ix) public class Test { ++x;
public static void main(String[] args) { y--;
int x = 1, y = 2, z = 5; int z = x < y ? x : y;
System.out.println("x: " +(!((x + 2) == (1 + 2)))); System.out.println(z);
System.out.println("y: " +(!(y == z))); }
System.out.println("z>x: " +(!(z > x))); }
if(!(x == y) && ((y + 5) > z) && (!((z - 3) == 0))){
System.out.println("Hello"); } } } xiii) public class Test {
public static void main(String[] args)
x) public class OROperatorExample { {
public static void main(String[] args) { int x = 2;
int x = 1; int y = 4;
int y = 2; int z = x++/2 == y-- % 3 ? x : y;
int z = 5; System.out.println(z); }}
System.out.println("x: " +(x == 1));
System.out.println("y: " +(y == z)); xiv) public class BitwiseOperatorsEx {
System.out.println("z > x: " +(z > x)); public static void main(String[] args)
{
if(x == 1 || x > y || x > z) { int a = 2, b = 10;
System.out.println("One"); } System.out.println("(2 & 10): " +(a & b));
if(x == y || y == 2 || z == 5){ System.out.println("(2 | 10): " +(a | b));
System.out.println("Two"); } System.out.println("(2 ^ 10): " +(a ^ b));
if(x == y || y == z || z == x){ System.out.println("~10: " +~b);
System.out.println("Three"); }}} }
}
xi) public static void main(String[] args) {
int x = 1; xv) public static void main(String[] args) {
int y = 2; int a = 1;
int z = 5; ++a;
System.out.println("x: " +(!((x + 2) == (1 + 2)))); int b = a++;
System.out.println("y: " +(!(y == z))); a--;
System.out.println("z > x: " +(!(z > x))); int c= --a;
if(!(x == y) && ((y + 5) > z) && (!((z - 3) == 0))){ int x = a * 10 / (b - c);
System.out.println("Hello"); }}} System.out.println("a = " +a);
System.out.println("x = " +x);
xii) public class Test { }
public static void main(String[] args)
{
int x = 20;
int y = 20;

You might also like