Sail E0 Webinar

MCQs

Total Questions : 65 | Page 7 of 7 pages
Question 61.


What will be the output of the program?


class Test
{
public static void main(String [] args)
{
Test p = new Test();
p.start();
}
void start()
{
boolean b1 = false;
boolean b2 = fix(b1);
System.out.println(b1 + " " + b2);
}
boolean fix(boolean b1)
{
b1 = true;
return b1;
}
}
  1.    true true
  2.    false true
  3.    true false
  4.    false false
 Discuss Question
Answer: Option B. -> false true

The boolean b1 in the fix() method is a different boolean than the b1 in the start() method. 

The b1 in the start() method is not updated by the fix() method.


Question 62.

Modulus operator, %, can be applied to which of these?


  1.    Integers
  2.    Floating – point numbers
  3.    Both Integers and floating - point numbers.
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> Both Integers and floating - point numbers.

Modulus operator can be applied to both integers and floating point numbers. .



Question 63.

Which of the following can be operands of arithmetic operators?


  1.    Numeric
  2.    Boolean
  3.    Characters
  4.    Both Numeric & Characters
 Discuss Question
Answer: Option D. -> Both Numeric & Characters

The operand of arithmetic operators can be any of numeric or character type, But not boolean.




Question 64.


What will be the output of the program?


class PassA
{
public static void main(String [] args)
{
PassA p = new PassA();
p.start();
}
void start()
{
long [] a1 = {3,4,5};
long [] a2 = fix(a1);
System.out.print(a1[0] + a1[1] + a1[2] + " ");
System.out.println(a2[0] + a2[1] + a2[2]);
}
long [] fix(long [] a3)
{
a3[1] = 7;
return a3;
}
}
  1.    12 15
  2.    15 15
  3.    3 4 5 3 7 5
  4.    3 7 5 3 7 5
 Discuss Question
Answer: Option B. -> 15 15

Output: 15 15

The reference variables a1 and a3 refer to the same long array object. When the [1] 

element is updated in the fix() method, it is updating the array referred to by a1. The 

reference variable a2 refers to the same array object.

So Output: 3+7+5+" "3+7+5

Output: 15 15 Because Numeric values will be added


Question 65.

Which of these is not a bitwise operator?


  1.    &
  2.    &=
  3.    |=
 Discuss Question
Answer: Option D. -> 15 15

<= is a relational operator.


Latest Videos

Latest Test Papers