Multiple Choice Question ( JAVA )
---------------------->>>> Click Here :Subscribe to click <<<<<--------------------------
PART - 01
Q1 . What is size of float and double ?
a. 32 and 64 b. 32 and 32
c. 64 and 64 d. 64 and 32
Ans : 32 and 64
Q2 . What will be the output ?
short x=10;
x*=5;
System.out.println(x);
a. 50 b. 10
c. No output d. Compilation Error
Ans : Compilation Error
Q3. find the error in which line ?
class A{
final a;
System.out.println(a);
}
a. Line 1 b. Line 2
c. Line 3 d. No Error
Ans : Line 2
Q4. Find the length of String ?
a. using string.length()
b. using string.length
Ans : a
Q5. Find the output ?
class A{
.........
}
class Solution{
Box box[]={b1,b2,b3,b4,b5};
for(int i=0;i<box.length();i++){
System.out.println(box[i]);
}
}
a. No Error b. error
c. print all array object d. none of these
Q6. Objects includes ?
a. Attributes b. both
c. Behaviour d. none
Ans : c
Q7. String str="I like JAVA";
System.out.println(str.length());
a. 11 b. 10
c. 9 d. 3
Ans : a
Q8. What is the extension of java file ?
Ans : .java
---------------------->>>> Click Here :Subscribe to click <<<<<--------------------------
PART - 02
---------------------->>>> Click Here :Subscribe to click <<<<<--------------------------
Q9. Which of this is Super class of every class ?
a. String class b. Object class
c. Abstract class d. ArrayList class
Ans : b
Q10. Which modifier is used to prevent any method or attribute to be not visible to external classes ?
a. private b. protected
c. public d. default
Ans : a
Q11. All the classes can be simultaneously imported by which wildcard ?
Ans : *
Q12. Which of the following is the correct declaration of array of size 10 ?
a. int arr[10];
b. int arr[10]=new int[10];
c. int arr[]=new int[10];
d. int arr[]={10 elements };
Ans : c and d
Q13. public class Solution{
public static void main(String[] args){ byte x = 127; x++; x++; System.out.print(x); } }Q14. Arrays in java are -
a. object references b. primitive data type
c. objects d. none
Ans : objects
Q15. Identify what can directly access and change the value of the variable res.
Package com.mypackage;
Public class Solution{
Private int res = 100;
}
a. Any class b. Solution class
c. Any class that extends Solution class d. None
Ans : b
Q16. Identify the output of the following program.
String str = “abcde”;
System.out.println(str.substring(1, 3));
a. abc b. bc
c. bcd d. cd
Ans : b
Q17. Identify the output of the following program.
String str = “Hellow”;
System.out.println(str.indexOf(t));
a. 4 b. 3
c. 6 d. -1
Ans : d ( because t is not present in the string )
Q18. Identify the output of the following program.
Public class Test{
Public static void main(String argos[]){
String str1 = “one”;
String str2 = “two”;
System.out.println(str1.concat(str2));
}
}
Ans : onetwo
---------------------->>>> Click Here :Subscribe to click <<<<<--------------------------
Part : 03
Q19. How many objects will be created in the following?
String a = new String(“Interviewbit”);
String b = new String(“Interviewbit”);
Strinc c = “Interviewbit”;
String d = “Interviewbit”;
Ans : 3
Q20. Find the output of the following code.
int ++a = 100;
System.out.println(++a);
Ans : compilation error ( not a valid identifier )
Q21. Find the output of the following code.
Public class Solution{
Public static void main(String args[]){
Int i;
for(i = 1; i < 6; i++){
if(i > 3) continue;
}
System.out.println(i);
}
}
Ans : 6
Q22. Identify the infinite loop ?
a. for(;;) b. for(int i=0;i<1;i--)
c. for(int i=0;;i++) d. All of the above
Ans : d
Q23. Evaluate the following Java expression, if x=3, y=5, and z=10:
++z + y - y + z + x++
Ans : 25
Q24. What are the types of memory allocated in memory in java?
a. Heap memory
b. Stack memory
c. Both A and B
d. None of these
Answer: C) Both A and B
Q25. What is the entry point of a program in Java?
a. main() method
b. The first line of code
c. Last line of code
d. main class
Answer: A) main() method
---------------------->>>> Click Here :Subscribe to click <<<<<--------------------------
---------------------- // THANK YOU // ------------------------------
Comments
Post a Comment