Question 1 of 25
Hints left: 3
Q1
What is the result of the expression true && false in Java?
Q2
Which of these method of class String is used to compare two String objects for their equality?
Q3
What will be the output of the following Java program? class output { public static void main(String args[]) { StringBuffer c = new StringBuffer("Hello"); StringBuffer c1 = new StringBuffer(" World"); c.append(c1); System.out.println(c); } }
Q4
Which of the following statement is correct?
Q5
What is the result of the expression 10 / 3 in Java?
Q6
Which operator is used for division in Java?
Q7
What will be the output of the following Java code? class output { public static void main(String args[]) { String a = "hello i love java"; System.out.println(a.indexOf('i')+" "+a.indexOf('o') +" "+a.lastIndexOf('i')+" "+a.lastIndexOf('o')); } }
Q8
What is the value of the expression 7 % 3 in Java?
Q9
What will be the output of the following Java code? class output { public static void main(String args[]) { char c[]={'a', '1', 'b' ,' ' ,'A' , '0'}; for (int i = 0; i < 5; ++i) { if(Character.isDigit(c[i])) System.out.println(c[i]+" is a digit"); if(Character.isWhitespace(c[i])) System.out.println(c[i]+" is a Whitespace character"); if(Character.isUpperCase(c[i])) System.out.println(c[i]+" is an Upper case Letter"); if(Character.isLowerCase(c[i])) System.out.println(c[i]+" is a lower case Letter"); i=i+3; } } }
Q10
What will be the output of the following Java code? class output { public static void main(String args[]) { String chars[] = {"a", "b", "c", "a", "c"}; for (int i = 0; i < chars.length; ++i) for (int j = i + 1; j < chars.length; ++j) if(chars[i].compareTo(chars[j]) == 0) System.out.print(chars[j]); } }
Q11
In the following Java code, what can directly access and change the value of the variable name? package test; class Target { public String name = "hello"; }
Q12
What will be the output of the following Java code? class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Hello World"); s1.insert(6 , "Good "); System.out.println(s1); } }
Q13
What will s2 contain after following lines of Java code? String s1 = "one"; String s2 = s1.concat("two")
Q14
Which of these operators can be used to concatenate two or more String objects?
Q15
What will be the output of the following Java program? class output { public static void main(String args[]) { StringBuffer c = new StringBuffer("Hello"); c.delete(0,2); System.out.println(c); } }
Q16
What will be the output of the following Java code? class output { public static void main(String args[]) { StringBuffer c = new StringBuffer("Hello"); System.out.println(c.length()); } }
Q17
What will be the output of the following Java code? class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Hello"); s1.setCharAt(1,'x'); System.out.println(s1); } }
Q18
What is the result of the expression 5 + 3 * 2 in Java?
Q19
Which of these methods is an alternative to getChars() that stores the characters in an array of bytes?
Q20
Which of these methods of class StringBuffer is used to extract a substring from a String object?
Q21
What will be the output of the following Java code? public class Boxer1 { Integer i; int x; public Boxer1(int y) { x = i+y; System.out.println(x); } public static void main(String[] args) { new Boxer1 (new Integer(4)); } }
Q22
What will be the output of the following Java program? class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Hello"); StringBuffer s2 = s1.reverse(); System.out.println(s2); } }
Q23
What will be the output of the following Java program? class String_demo { public static void main(String args[]) { char chars[] = {'a', 'b', 'c'}; String s = new String(chars); String s1 = "abcd"; int len1 = s1.length(); int len2 = s.length(); System.out.println(len1 + " " + len2); } }
Q24
What will be the output of the following Java code? class output { public static void main(String args[]) { String s1 = "Hello"; String s2 = new String(s1); String s3 = "HELLO"; System.out.println(s1.equals(s2) + " " + s2.equals(s3)); } }
Q25
Which of the following is a unary operator in Java?