πŸ“Š JAVA
Q. Find the output of the following program.
Code:
public class Solution{
       public static void main(String[] args){
                     short x = 10;
                     x =  x * 5;
                     System.out.print(x);
       }
}
  • (A) 50
  • (B) 10
  • (C) Compile error
  • (D) Exception
πŸ’¬ Discuss
βœ… Correct Answer: (C) Compile error
πŸ“Š JAVA
Q. Find the output of the following program.
Code:
public class Solution{
       public static void main(String[] args){
                     byte x = 127;
                     x++;
                     x++;
                     System.out.print(x);
       }
}
  • (A) -127
  • (B) 127
  • (C) 129
  • (D) 2
πŸ’¬ Discuss
βœ… Correct Answer: (A) -127
πŸ“Š JAVA
Q. Select the valid statement.
  • (A) char[] ch = new char(5)
  • (B) char[] ch = new char[5]
  • (C) char[] ch = new char()
  • (D) char[] ch = new char[]
πŸ’¬ Discuss
βœ… Correct Answer: (B) char[] ch = new char[5]
πŸ“Š JAVA
Q. Find the output of the following program
Code:
public class Solution{
       public static void main(String[] args){
               int[]  x = {120, 200, 016};
               for(int i = 0; i < x.length; i++){
                        System.out.print(x[i] + “ “);
               }                   
       }
}
  • (A) 120 200 016
  • (B) 120 200 14
  • (C) 120 200 16
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (B) 120 200 14
πŸ“Š JAVA
Q. When an array is passed to a method, what does the method receive?
  • (A) The reference of the array
  • (B) A copy of the array
  • (C) Length of the array
  • (D) Copy of first element
πŸ’¬ Discuss
βœ… Correct Answer: (A) The reference of the array
πŸ“Š JAVA
Q. Select the valid statement to declare and initialize an array.
  • (A) Int[] A = {}
  • (B) Int[] A = {1,2,3}
  • (C) Int[] A = (1,2,3)
  • (D) Int[][] A = {1,2,3}
πŸ’¬ Discuss
βœ… Correct Answer: (B) Int[] A = {1,2,3}
πŸ“Š JAVA
Q. Find the value of A[1] after execution of the following program.
Code:
int[] A = {0,2,4,1,3};
for(int i = 0; i < a.length; i++){
    a[i] = a[(a[i] + 3) % a.length];
}
  • (A) 0
  • (B) 1
  • (C) 2
  • (D) 3
πŸ’¬ Discuss
βœ… Correct Answer: (B) 1
πŸ“Š JAVA
Q. Arrays in java are
  • (A) Object references
  • (B) Objects
  • (C) Primitive data type
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (B) Objects

Explanation: Arrays are objects in java. It is a container that holds a fixed number of items of a single type.

πŸ“Š JAVA
Q. When is the object created with new keyword?
  • (A) At run time
  • (B) At compile time
  • (C) Depends on the code
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (A) At run time
πŸ“Š JAVA
Q. Identify the corrected definition of a package.
  • (A) A package is a collection of editing tools
  • (B) A package is a collection of classes
  • (C) A package is a collection of classes and interfaces
  • (D) A package is a collection of interfaces
πŸ’¬ Discuss
βœ… Correct Answer: (C) A package is a collection of classes and interfaces