πŸ“Š JAVA
Q. Identify the correct restriction on static methods.

1. They must access only static data
2. They can only call other static methods.
3. They cannot refer to this or super.
  • (A) 1 and 2
  • (B) 2 and 3
  • (C) Only 3
  • (D) 1, 2 and 3
πŸ’¬ Discuss
βœ… Correct Answer: (D) 1, 2 and 3
πŸ“Š JAVA
Q. Identify the keyword among the following that makes a variable belong to a class,rather than being defined for each instance of the class.
  • (A) Final
  • (B) Static
  • (C) Volatile
  • (D) Abstract
πŸ’¬ Discuss
βœ… Correct Answer: (B) Static
πŸ“Š JAVA
Q. Identify what can directly access and change the value of the variable res.
Code:
Package com.mypackage;
Public class Solution{
       Private int res = 100;
}
  • (A) Any class
  • (B) Only solution class
  • (C) Any class that extends solution
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (B) Only solution class
πŸ“Š JAVA
Q. In which of the following is toString() method defined?
  • (A) java.lang.Object
  • (B) java.lang.String
  • (C) java.lang.util
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (A) java.lang.Object
πŸ“Š JAVA
Q. compareTo() returns
  • (A) True
  • (B) False
  • (C) An int vale
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (C) An int vale
πŸ“Š JAVA
Q. Identify the output of the following program
Code:
String str = “abcde”;
System.out.println(str.substring(1, 3));
  • (A) abc
  • (B) bc
  • (C) bcd
  • (D) cd
πŸ’¬ Discuss
βœ… Correct Answer: (B) bc
πŸ“Š JAVA
Q. Identify the output of the following program.
Code:
String str = “Hellow”;
System.out.println(str.indexOf(‘t));
  • (A) 0
  • (B) 1
  • (C) true
  • (D) -1
πŸ’¬ Discuss
βœ… Correct Answer: (D) -1
πŸ“Š JAVA
Q. Identify the output of the following program.
Code:
Public class Test{
          Public static void main(String argos[]){
                   String str1 = “one”;
                   String str2 = “two”;
                   System.out.println(str1.concat(str2));
          }
}
  • (A) one
  • (B) two
  • (C) ontwo
  • (D) twoone
πŸ’¬ Discuss
βœ… Correct Answer: (C) ontwo
πŸ“Š JAVA
Q. What does the following string do to given string str1.
Code:
String str1 = “chandrakant”.replace(‘c’,’s’);
  • (A) Replaces single occurance of c to s
  • (B) Replaces all occurance of c to s
  • (C) Replaces single occurance of s to c
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (B) Replaces all occurance of c to s
πŸ“Š JAVA
Q. To which of the following does the class string belong to.
  • (A) java.lang
  • (B) java.awt
  • (C) java.applet
  • (D) java.string
πŸ’¬ Discuss
βœ… Correct Answer: (A) java.lang