0

programming languages Online Quiz - 295

Description: programming languages Online Quiz - 295
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

What formula should be used to get a date, 2 months from todays date?

  1. @Text

  2. @Adjust

  3. @Date

  4. @Month


Correct Option: B

If I would need to attach document ina field what type of field has to be created?

  1. Text

  2. Attach Text

  3. Text Lite

  4. Rich Text


Correct Option: D
  1. public static void parse(String str) { 12. try { 13. float f= Float.parseFloat(str); 14. } catch (NumberFormatException nfe) { 15. f= 0; 16. } finally { 17. System.out.println(f); 18. } 19. } 20. public static void main(String[] args) { 21. parse(”invalid”); 22. } What is the result?
  1. 0.0

  2. Compilation fails

  3. A ParseException is thrown by the parse method at runtime

  4. A NumberFormatException is thrown by the parse method at runtime


Correct Option: B

Click the Exhibit button. 1. public class Test { 2. int x= 12; 3. public void method(int x) { 4. x+=x; 5. System.out.println(x); 6. } 7. } Given: 34. Test t = new Test(); 35. t.method(5); What is the output from line 5 of the Test class?

  1. 5

  2. 10

  3. 12

  4. 17


Correct Option: B

Given: 55. int []x= {1, 2,3,4, 5}; 56.int y[] =x; 57. System.out.println(y[2]); Which is true?

  1. Line 57 will print the value 2

  2. Line 57 will print the value 3

  3. Compilation will fail because of an error in line 55

  4. Compilation will fail because of an error in line 56


Correct Option: B

Given: 35. String #name = “Jane Doe”; 36.int$age=24; 37. Double_height = 123.5; 38. double~temp = 37.5; Which two are true? (Choose two.)

  1. Line 35 will not compile.

  2. Line 36 will not compile

  3. Line 37 will not compile.

  4. Line 38 will not compile.


Correct Option: A,D

Given: 11. public enum Title { 12. MR(”Mr.”), MRS(”Mrs.”), MS(”Ms.”); 13. private final String title; 14. private Title(String t) { title = t; } 15. public String format(String last, String first) { 16. return title + “ “ + first + “ “ + last; 17. } 18. } 19. public static void main(String[] args) { 20. System.out.println(Title.MR.format(”Doe”, “John”)); 21. } What is the result?

  1. Mr. John Doe

  2. An exception is thrown at runtime

  3. Compilation fails because of an error in line 12

  4. Compilation fails because of an error in line 15


Correct Option: A

Given: 11. public static void main(String[] args) { 12. Object obj =new int[] { 1,2,3 }; 13. int[] someArray = (int[])obj; 14. for (int i: someArray) System.out.print(i +“ “) 15. } ‘What is the result?

  1. 1 2 3

  2. Compilation fails because of an error in line 12.

  3. Compilation fails because of an error in line 13

  4. Compilation fails because of an error in line 14


Correct Option: A
  1. Foo.beta() is a valid invocation of beta().

  2. Foo.alpha() is a valid invocation of alpha().

  3. Method beta() can directly call method alpha().

  4. Method alpha() can directly call method beta().


Correct Option: B,C

A programmer needs to create a logging method that can accept an arbitrary number of arguments. For example, it may be called in these ways: logIt(”log message 1 “); logIt(”log message2”,”log message3”); logIt(”log message4”, “log message5”, “log message6); Which declaration satisfies this requirement?

  1. public void logIt(String * msgs)

  2. public void logIt(String [] msgs)

  3. public void logIt(String... msgs)

  4. public void logIt(String msg1, String msg2, String msg3)


Correct Option: C

Click the Exhibit button. 1. public class A { 2. 3. private int counter = 0; 4. 5. public static int getInstanceCount() { 6. return counter; 7. } 8. 9. public A() { 10. counter++; 11. } 12. 13. } Given this code from Class B: 25.A a1 =new A(); 26. A a2 =new A(); 27. A a3 =new A(); 28. System.out.printIn(A.getInstanceCount() ); What is the result?

  1. Compilation of class A fails

  2. Line 28 prints the value 3 to System.out

  3. Line 28 prints the value 1 to System.out.

  4. A runtime error occurs when line 25 executes


Correct Option: A
  1. int foo() { /* more code here */ }

  2. void foo() { /* more code here */ }

  3. public void foo() { /* more code here */ }

  4. protected void foo() { /* more code here */ }


Correct Option: B,C,D
- Hide questions