Java, JavaScript, and C++ Programming Quiz
Test your knowledge of Java (exceptions, polymorphism, packages), JavaScript (history, browser support), and C++ (STL containers, iterators, casting operators)
Questions
What happen if the exception is not caught?
- nothing happen, excution will continue.
- it will be handled by compiler, and excution stops.
- the exception will be rethrown
- terminate() function will be called and execution stops.
Which of the following represents the correct syntax for re-throwing an exception.
- try {throw 3;} catch(int i){ rethrow; }
- try {throw 3; rethrow ;} catch(int i){}
- try {throw 3;} catch(int i){ rethrow 3; }
- try {throw 3;} catch(int i){ throw; }
range_error is which type of exception.
- logical_error
- runtime_error
- domain_error
- bad_exception
Which of the following is used for casting inherently incompatible pointers.
- static_cast
- reinterpret_cast
- dynamic_cast
- const_cast
What is time complexity of Insertions or deletions at positions other than the end in "vector STL template class"
- O(1)
- O(N2)
- O(log N)
- O(N)
which of the following is not an associative container
- map
- multiset
- priority queue
- multimap
which of the following iterator must support *, ==, =- and ++ operations
- Input Iterator
- Output Iterator
- Forward Iterator
- None of these
Which company first implemented the JavaScript language?
- Microsoft Corp.
- Netscape Communications Corp.
- Sun Microsystems Corp.
- Consortium of the above companies
What are the purposes of comments in JavaScript code?
- Comments can make the code easier to understand.
- Comments can help hide the code from browsers that cannot interpret JavaScript.
- Comments can help display a warning to users of old browsers that do not support JavaScript.
- All of above.
When was the first release of a browser supporting JavaScript?
- 1995
- 1996
- 1997
- 1998
he original name of JavaScript was
- JavaScript
- LiveScript
- WireScript
- ECMAScript
Which of the following browsers was the first to support JavaScript?
- Microsoft Internet Explorer 2.0 beta
- Netscape Navigator 2.0 beta
- Opera 2.0 beta
- SunSoft HotJava 2.0 beta
Which of the following browsers does not support JavaScript?
- Microsoft Internet Explorer 3.02
- Netscape Navigator 3.02
- Opera 3.51
- SunSoft HotJava 1.0
The JavaScript international standard is called
- JavaScript 1.3 Standard
- ISO-262 Standard
- IEEE-262 Standard
- None of the above
Which of the following statements best describes the relationship between JavaScript and DHTML?
- JavaScript is DHTML plus CSS plus Document Object Model.
- DHTML is Document Object Model plus JavaScript plus CSS.
- Document Object Model is JavaScript plus DHTML plus CSS.
- JavaScript has nothing to do with DHTML.
Which JavaScript version was the first to allow image swapping, or image roll-overs?
- JavaScript 1.0
- JavaScript 1.1
- JavaScript 1.2
- JavaScript 1.3
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?
- doStuffx = 5 main x = 5
- Compilation fails.
- doStuffx = 6 main x = 5
- An exception is thrown at runtime
- doStuffx = 6 main x = 6
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?
- import sun.scjp.; import static sun.scjp.Color.;
- import sun.scjp.Color; import static sun.scjp.Color.*;
- import sun.scjp.Color.*;
- import sun.scjp.Color; import static sun.scjp.Color.GREEN;
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?
- Compilation fails.
- TestB
- TestA
- An exception is thrown at runtime
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?
- Line 46 will compile if the enclosing method throws a TestException.
- Class A will not compile.
- Line 46 will compile if enclosed in a try block, where TestException is caught
- Line 45 can throw the unchecked exception TestException.