0% found this document useful (0 votes)
37 views5 pages

First QUIZ Test Solution

The document contains examples of Java code snippets that demonstrate the use of operators such as increment, decrement, arithmetic, assignment, and logical operators. Each code snippet prints the output of operations on various integer variables. For example, one snippet shows the increment and decrement operators being used on a variable x and printing the results, while another demonstrates the addition and assignment operators.

Uploaded by

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

First QUIZ Test Solution

The document contains examples of Java code snippets that demonstrate the use of operators such as increment, decrement, arithmetic, assignment, and logical operators. Each code snippet prints the output of operations on various integer variables. For example, one snippet shows the increment and decrement operators being used on a variable x and printing the results, while another demonstrates the addition and assignment operators.

Uploaded by

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

First QUIZ Test

Sec-2C3

1.

public class QuizTest


{
public static void main(String[] args)
{
int x = 50;
System.out.println(x);
System.out.println(++x);
System.out.println(x++);
System.out.println(x);
}
}

50
51
51
52

2.

public class QuizTest


{
public static void main(String[] args)
{
int x = 100;
System.out.println(x-- + --x);
System.out.println(--x + x--);
System.out.println(++x + x++);
System.out.println(x++ + ++x);
}
}

198
194
194
198
3.

public class QuizTest


{
public static void main(String[] args)
{
int a = 5 + 7 % 2 -3;
int b = a + 9 - 6 % 3;
System.out.println(a + " " + b);
boolean b1 = ++a>3 && b--<12;
System.out.println(a + " " + b + " "+b1);
}
}

3 12
4 11 false

4.

public class QuizTest


{
public static void main(String[] args)
{
int a1 = -127;
int a2 = 100;
byte b = (byte)(a1+a2);
System.out.println(a1 + " " + a2 + " " +b);
int c = (a2 + a1)*++b;
System.out.println(c + " " + b);
}
}

-127 100 -27


702 -26

5.

public class QuizTest


{
public static void main(String[] args)
{
int x = 55, y = 65;
int z = ++x + (y = y++ + x);
System.out.println(x + " " + y + " " + z);
System.out.println(2 + '2' + "2");
}
}

56 121 177
522

Sec-2B3
1.

class Q1
{
public static void main(String[] args)
{
int x = 50;
System.out.println(x);
System.out.println(x--);
System.out.println(--x);
System.out.println(x);
}
}

50
50
48
48

2.

class Q2
{
public static void main(String[] args)
{
int x = 100;
System.out.println(x++ + ++x);
System.out.println(++x + x++);
System.out.println(--x + x--);
System.out.println(x-- + --x);
}
}

202
206
206
202

3.

class Q3
{
public static void main(String[] args)
{
int a = 5 - 7 % 2 +3;
int b = a % 5 - 6 * 3 / 5;
System.out.println(a + " " + b);
boolean b1 = ++a>3 && b--<12;
System.out.println(a + " " + b + " "+b1);
}
}

7 -1
8 - 2 true

4.

class Q4
{
public static void main(String[] args)
{
int a1 = 127;
int a2 = 130;
byte b = (byte)(a1 + a2);
System.out.println(a1 + " " + a2 + " " + b);
int c = (a2 - a1)*b++;
System.out.println(c + " " + b);
}
}

127 130 1
32
5.

class HelloWorld
{
public static void main(String[] args)
{
int x = 25, y = 100;
int z = ++x + (y = y++ + x);
System.out.println(x + " " + y + " " + z);
System.out.println(5 + '5' + "5");
}
}

26 126 152
585

You might also like