Tag: programming languages

Questions Related to programming languages

What is the result of compiling and running the following code ? 1. StringBuffer s1=new StringBuffer("hello"); 2. StringBuffer s2=new StringBuffer("hello"); 3. Float f1=9.0F; 4. Double f2=9.0; 5. System.out.print(f1.equals(f2)); 6. System.out.print(s1==s2); 7. System.out.print(s1.equals(s2));

  1. Prints "truetruetrue"

  2. Prints "falsefalsetrue"

  3. Prints "falsefalsefalse"

  4. Compiler error on line 5

  5. Compiler error on line 7

  6. None


Correct Option: B
  1. Compiler error: String and StringBuffer objects cannot be compared

  2. ClassCastException: String and StringBuffer objects cannot be compared

  3. Prints "true"

  4. Prints "false"


Correct Option: D
  1. String[] s =f.list();

  2. File[] files=f.list();

  3. File[] files=f.listFiles();

  4. List files=f.listFiles();


Correct Option: A,C

Which of the following are true about the readPassword() method of the Console class? choose two

  1. Its return type is String

  2. It reads the password from the console

  3. It has echoing disabled

  4. It takes a single argument

  5. None of them


Correct Option: B,C

What is the result of compiling and running the following program? import java.util.Arrays; class Split2 { public static void main(String[] args) { String str = "She sells sea shells"; System.out.println(Arrays.toString(str.split("\s"))); } }

  1. Compiler error

  2. An exception is thrown at runtime

  3. Prints [She, sells, sea, shells]

  4. Prints [he, ells, ea, hells]

  5. Prints []


Correct Option: C
  1. Internet Explorer 5.0

  2. Netscape 7.1

  3. Firefox 1.0

  4. All of Above


Correct Option: D
  1. strtod()

  2. srttoi()

  3. atoi()

  4. None of these


Correct Option: C