0% found this document useful (0 votes)
13 views6 pages

Operators 1 (2)

The document outlines a technical training assessment for Java operators, divided into two parts: Part A consists of 18 multiple-choice questions and Part B contains 16 programming tasks. Each question tests knowledge of Java syntax, operators, and programming logic. The total score for the assessment is 50 marks, with specific marks allocated to each part.
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)
13 views6 pages

Operators 1 (2)

The document outlines a technical training assessment for Java operators, divided into two parts: Part A consists of 18 multiple-choice questions and Part B contains 16 programming tasks. Each question tests knowledge of Java syntax, operators, and programming logic. The total score for the assessment is 50 marks, with specific marks allocated to each part.
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/ 6

Placement Technical Training-JAVA

Operators
Level-1
TOTAL=50MARKS(18+32)
PART-A(18*1=18)

1.Predict the output of following Java Program

class Test {
public static void main(String args[]) {
int x = -4;
System.out.println(x>>1);
int y = 4;
System.out.println(y>>1);
}
}

2. Predict the output of following Java Program

class Test {
public static void main(String args[]) {
System.out.println(10 + 20 + "GeeksQuiz");
System.out.println("GeeksQuiz" + 10 + 20);
}
}

3. Which of the following is not an operator in Java?

1. instanceof
2. sizeof
3. new
4. >>>=

4. Predict the output of following Java Program

class Base {}
class Derived extends Base {
public static void main(String args[]){
Base a = new Derived();
System.out.println(a instanceof Derived);
}}
5. Predict the output of following Java Program

class Test
{
public static void main(String args[])
{
String s1 = "geeksquiz";
String s2 = "geeksquiz";
System.out.println("s1 == s2 is:" + s1 == s2);
}
}

6. Predict the output of following Java Program

class Test
{
boolean[] array = new boolean[3];
int count = 0;
void set(boolean[] arr, int x)
{
arr[x] = true;
count++;
}
void func()
{
if(array[0] && array[++count - 2] | array [count - 1])
count++;
System.out.println("count = " + count);
}

public static void main(String[] args) {


Test object = new Test();
object.set(object.array, 0);
object.set(object.array, 1);
object.func();
}
}

7. In Java, after executing the following code what are the values of x, y
and z?

int x,y=10, z=12;


x=y++ + z++;
8.Choose the correct answer

public class MyClass {


public static void main(String[] args){
int a = 10;
System.out.println(a++++);
}}
(A) 11
(B) 12
(C) 13
(D) Compilation Error

9. Choose the correct answer

public class CppBuzz{


public static void main(String[] args){
int a = 10;
System.out.println(a++);
a++;
}}
(A) 10
(B) 11
(C) 12
(D) 13

10. Choose the correct answer

public class CppBuzz {


public static void main(String[] args){
int a = 10;
System.out.println(a*a++);
}}
(A) 100
(B) 110
(C) 121
(D) Compilation Error

11. Choose the correct answer

public class CppBuzz {


public static void main(String[] args){
int a = 10;
System.out.println(++a*a++);
}}
(A) 121
(B) 132
(C) 144
(D) 100

12. Choose the correct answer

public class CppBuzz {


public static void main(String[] args){
int a = 5+5*2+2*2+(2*3);
System.out.println(a);
}
}
(A) 138
(B) 264
(C) 41
(D) 25

13.Which of the following operators has more precedance in Java?

(A) -
(B) +
(C) *

14. Which of the following is not an operator in Java?

(A) |
(B) ^
(C) ~
(D) <->

15. Which of the following operator has more precedence?

(A) ()
(B) ++
(C) *
(D) >=

16. Which one of the following is an Unary operator in Java?

(A) ()
(B) *
(C) +
(D) ++
17. Which one of the following is Equality operator in Java?

(A) >=
(B) <=
(C) !=
(D) +=

18. Choose the correct answer


public class Main
{
public static void main(String[] args) {
int a = 10;

if(++a==11 || ++a==12)
++a;

System.out.println(a);
}
}
(A) 13
(B) 12
(C) 11
(D) 10

PART-A(16*2=32)

1.Length and breadth of a rectangle are 5 and 7 respectively. Write a program to calculate the
area and perimeter of the rectangle.

2.Write a program to calculate the perimeter of a triangle having sides of length 2,3 and 5 units.

3.Write a program to add 8 to the number 2345 and then divide it by 3. Now, the modulus of the
quotient is taken with 5 and then multiply the resultant value by 5. Display the final result.

4.Now, solve the above 3rd question using assignment operators (eg. +=, -=, *=).

5.Write a program to check if the two numbers 23 and 45 are equal.

6.Write a program to print the power of 7 raised to 5.

7.Assign values of variables 'a' and 'b' as 55 and 70 respectively and then check if both the
conditions 'a < 50' and 'a < b' are true.
8.Now solve the above question to check if atleast one of the conditions 'a < 50' or 'a < b' is true.

9.If the marks of Robert in three subjects are 78,45 and 62 respectively (each out of 100 ), write a
program to calculate his total marks and percentage marks.

10.Suppose the values of variables 'a' and 'b' are 6 and 8 respecrtively, write two programs to
swap the values of the two variables.
1 - first program by using a third variable
2 - second program without using any third variable
( Swapping means interchanging the values of the two variables E.g.- If entered value of x is 5
and y is 10 then after swapping the value of x and y should become 10 and 5 respectively.)

11.Write a program to convert Fahrenheit into Celsius.

12.The total number of students in a class are 90 out of which 45 are boys. If 50% of the total
students secured grade 'A' out of which 20 are boys, then write a program to calculate the total
number of girls getting grade 'A'.

13.Write a program to calculate the sum of the first and the second last digit of a 5 digit.
E.g.- NUMBER : 12345 OUTPUT : 1+4=5

14.Take a 4 digit number. Write a program to display a number whose digits are 2 greater than
the corresponding digits of the number TAKEN.
For example, if the number which was taken is 5696, then the displayed number should be 7818.

15.Write a program to calculate the sum of the digits of a 3-digit number.


Number : 132 Output : 6

16.Write a program to reverse a 3-digit number. E.g.-Number : 132 Output : 231

You might also like