Tag: technology

Questions Related to technology

How do objects pass messages in Java?

  1. They pass messages by modifying each other's fields

  2. They pass messages by calling each other's instance methods

  3. They pass messages by modifying the static variables of each other's classes

  4. They pass messages by calling static methods of each other's classes


Correct Option: B

Which statement is true?

  1. new and delete are keywords in the Java language

  2. try, catch, and thrown are keywords in the Java language

  3. return, goto, and default are keywords in the Java language

  4. for, while, and next are keywords in the Java language


Correct Option: D

Which of the following primitive data types are integer types?

  1. Type boolean

  2. Type float

  3. Type byte

  4. Type double


Correct Option: C

Which of the following lines are not valid declarations?

  1. char a = '\u0061';

  2. char 'a' = 'a';

  3. char \u0061 = 'a';

  4. ch\u0061r a = 'a';


Correct Option: B

Which of the following expressions evaluates to true?

  1. (false | true)

  2. (null != null)

  3. (4 <= 4)

  4. (true & false)


Correct Option: A,C

AI Explanation

To answer this question, we need to evaluate each expression and determine which ones evaluate to true.

Option A) (false | true) - This expression uses the bitwise OR operator (|) to combine the values false and true. The result of the bitwise OR operator is true if at least one of the operands is true. In this case, since the second operand is true, the expression evaluates to true.

Option B) (null != null) - This expression checks for inequality between two null values. In Java, null represents the absence of a value. When comparing null values, they are considered equal, so the expression evaluates to false.

Option C) (4 <= 4) - This expression uses the less than or equal to operator (<=) to compare the values 4 and 4. Since 4 is equal to 4, the expression evaluates to true.

Option D) (true & false) - This expression uses the bitwise AND operator (&) to combine the values true and false. The result of the bitwise AND operator is true only if both operands are true. In this case, since one of the operands (false) is false, the expression evaluates to false.

Therefore, the expressions that evaluate to true are A) (false | true) and C) (4 <= 4).

1.Set s = new HashSet(); 2.s.add("JAVA"); 3.s.add(new Integer(5)); Line 3 will give ClassCast Exception because Two different types of object are getting added.

  1. True

  2. False


Correct Option: B