0
Alien head

programming languages Online Quiz - 139

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

Class TestException 1. public class TestException extends Exception { 2. } Class A: 1. public class A { 2. 3. public String sayHello(String name) throws TestException { 4. 5. if(name == null) { 6. throw new TestException(); 7. } 8. 9. return “Hello “+ name; 10. } 11. 12. } A programmer wants to use this code in an application: 45. A a=new A(); 46. System.out.println(a.sayHello(”John”)); Which are true?

  1. Line 46 will compile if the enclosing method throws a TestException.

  2. Class A will not compile.

  3. Line 46 will compile if enclosed in a try block, where TestException is caught

  4. Line 45 can throw the unchecked exception TestException.


Correct Option: A,C

Given: class TestA { public void start() { System.out.println(”TestA”); } } public class TestB extends TestA { public void start() { System.out.println(”TestB”); } public static void main(String[] args) { ((TestA)new TestB()).start(); } } What is the result?

  1. Compilation fails.

  2. TestB

  3. TestA

  4. An exception is thrown at runtime


Correct Option: B

Given: 1. package sun.scjp; 2. public enum Color { RED, GREEN, BLUE } 1. package sun.beta; 2. // insert code here 3. public class Beta { 4. Color g = GREEN; 5. public static void main( String[] argv) 6. { System.out.println( GREEN); } 7. } The class Beta and the enum Color are in different packages. Which two code fragments, inserted individually at line 2 of the Beta declaration, will allow this code to compile?

  1. import sun.scjp.; import static sun.scjp.Color.;

  2. import sun.scjp.Color; import static sun.scjp.Color.*;

  3. import sun.scjp.Color.*;

  4. import sun.scjp.Color; import static sun.scjp.Color.GREEN;


Correct Option: B,D

Given: public class Pass { public static void main(String [] args) { int x 5; Pass p = new Pass(); p.doStuff(x); System.out.print(” main x = “+ x); } void doStuff(int x) { System.out.print(” doStuff x = “+ x++); } } What is the result?

  1. doStuffx = 5 main x = 5

  2. Compilation fails.

  3. doStuffx = 6 main x = 5

  4. An exception is thrown at runtime

  5. doStuffx = 6 main x = 6


Correct Option: A

Which JavaScript version was the first to allow image swapping, or image roll-overs?

  1. JavaScript 1.0

  2. JavaScript 1.1

  3. JavaScript 1.2

  4. JavaScript 1.3


Correct Option: B

Which of the following statements best describes the relationship between JavaScript and DHTML?

  1. JavaScript is DHTML plus CSS plus Document Object Model.

  2. DHTML is Document Object Model plus JavaScript plus CSS.

  3. Document Object Model is JavaScript plus DHTML plus CSS.

  4. JavaScript has nothing to do with DHTML.


Correct Option: B

The JavaScript international standard is called

  1. JavaScript 1.3 Standard

  2. ISO-262 Standard

  3. IEEE-262 Standard

  4. None of the above


Correct Option: D

Which of the following browsers does not support JavaScript?

  1. Microsoft Internet Explorer 3.02

  2. Netscape Navigator 3.02

  3. Opera 3.51

  4. SunSoft HotJava 1.0


Correct Option: D

Which of the following browsers was the first to support JavaScript?

  1. Microsoft Internet Explorer 2.0 beta

  2. Netscape Navigator 2.0 beta

  3. Opera 2.0 beta

  4. SunSoft HotJava 2.0 beta


Correct Option: B

he original name of JavaScript was

  1. JavaScript

  2. LiveScript

  3. WireScript

  4. ECMAScript


Correct Option: B

When was the first release of a browser supporting JavaScript?

  1. 1995

  2. 1996

  3. 1997

  4. 1998


Correct Option: A

What are the purposes of comments in JavaScript code?

  1. Comments can make the code easier to understand.

  2. Comments can help hide the code from browsers that cannot interpret JavaScript.

  3. Comments can help display a warning to users of old browsers that do not support JavaScript.

  4. All of above.


Correct Option: D

Which company first implemented the JavaScript language?

  1. Microsoft Corp.

  2. Netscape Communications Corp.

  3. Sun Microsystems Corp.

  4. Consortium of the above companies


Correct Option: B

which of the following iterator must support *, ==, =- and ++ operations

  1. Input Iterator

  2. Output Iterator

  3. Forward Iterator

  4. None of these


Correct Option: C

which of the following is not an associative container

  1. map

  2. multiset

  3. priority queue

  4. multimap


Correct Option: C

What is time complexity of Insertions or deletions at positions other than the end in "vector STL template class"

  1. O(1)

  2. O(N2)

  3. O(log N)

  4. O(N)


Correct Option: D

Which of the following is used for casting inherently incompatible pointers.

  1. static_cast

  2. reinterpret_cast

  3. dynamic_cast

  4. const_cast


Correct Option: B

range_error is which type of exception.

  1. logical_error

  2. runtime_error

  3. domain_error

  4. bad_exception


Correct Option: B

Which of the following represents the correct syntax for re-throwing an exception.

  1. try {throw 3;} catch(int i){ rethrow; }

  2. try {throw 3; rethrow ;} catch(int i){}

  3. try {throw 3;} catch(int i){ rethrow 3; }

  4. try {throw 3;} catch(int i){ throw; }


Correct Option: D

What happen if the exception is not caught?

  1. nothing happen, excution will continue.

  2. it will be handled by compiler, and excution stops.

  3. the exception will be rethrown

  4. terminate() function will be called and execution stops.


Correct Option: D
+ View questions