Java
Which of these values can a boolean variable contain?
True & False
0 & 1
Any Integer
Both a and b
Which one is a valid declaration of a boolean
boolean b1 = 1;
boolean b2 = ‘false’;
boolean b3 = false;
boolean b4 = ‘true’
What is the output of this program?class mainclass { public static void main(String args[]) { char a = 'A'; a++; System.out.print((int)a); } }
66
67
65
64
Which of these constructors is used to create an empty String object
String()
String(void)
String(0)
None of the mentioned
Which of these is an incorrect statement
String objects are immutable, they cannot be changed.
String object can point to some other reference of String variable
StringBuffer class is used to store string in a buffer for later use
None of the mentioned
What is the string contained in s after following lines of code? StringBuffer s new StringBuffer(“Hello”); s.deleteCharAt(0);
Hell
ello
Hel
llo
Which of the following are incorrect form of StringBuffer class constructor?
StringBuffer()
StringBuffer(int size)
StringBuffer(String str)
StringBuffer(int size , String str)
Which of these methods can randomize all elements in a list?
rand()
randomize()
shuffle()
ambigous()
What is the output of this programimport java.util.*; 2. class Array 3. { 4. public static void main(String args[]) 5. { 6. int array[] = new int [5]; 7. for (int i = 5; i > 0; i--) 8. array[5 - i] = i; 9. Arrays.sort(array); 10. for (int i = 0; i < 5; ++i) 11. System.out.print(array[i]);; 12. } 13. }
12345
54321
1234
5432
What is the output of this program? public class BoxDemo 2. { 3. public static void addBox(U u, 4. java.util.List> boxes) 5. { 6. Box box = new Box<>(); 7. box.set(u); 8. boxes.add(box); 9. } 10. public static void outputBoxes(java.util.List> boxes) 11. { 12. int counter = 0; 13. for (Box box: boxes) 14. { 15. U boxContents = box.get(); 16. System.out.println("Box #" + counter + " contains [" + boxContents.toString() + "]"); 17. counter++; 18. } 19. } 20. public static void main(String[] args) 21. { 22. java.util.ArrayList> listOfIntegerBoxes = new java.util.ArrayList<>(); 23. BoxDemo.addBox(Integer.valueOf(10), listOfIntegerBoxes); 24. BoxDemo.outputBoxes(listOfIntegerBoxes); 25. } 26. }
10
Box #0 [10].
Box contains [10]
Box #0 contains [10]
{"name":"Java", "url":"https://www.quiz-maker.com/Q5OA6G6","txt":"Which of these values can a boolean variable contain?, Which one is a valid declaration of a boolean, What is the output of this program?class mainclass { public static void main(String args[]) { char a = 'A'; a++; System.out.print((int)a); } }","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}