Final SOLUTION



Answer all questions. Maximum 100 marks. Minimum 50 marks to pass the exam. Closed book, closed notes, closed electronics.
1. [5 marks] What is a Java Virtual Machine (JVM)? Does JVM have anything to do with Java programs running on multiple platforms. 2. [5 marks] Write a program to locate a substring within a larger string. 3. [5 marks] Given: 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)); } } What is the output? 4. [10 marks] How would you implement an algorithm using Classes, Objects, Hierarchy, Class Variables, and Instance Variables. 5. [5 marks] Why, in general, programmers have trouble when using == to compare Strings? 6. [5 marks] What are wrapper classes in Java? 7. [10 marks] A news magazine wants to conduct a survey across the four research universities in Alberta. For each university, the magazine wants to gather the number of departments, the number of students doing research in each department, courses taken by each research student, and marks scored by these students in courses. Design and develop a Class to capture this information. 8. [5 marks] Distinguish between Data Streams and Object Streams in Java. 9. [5 marks] How would you handle events using ChangeListener? 10. [5 marks] Explain why it takes much time to run an Applet having Swing components for the very first time? 11. [10 marks] Can applets communicate with other applets loaded from the same webpage? Explain. 12. [10 marks] What is concurrency in Java? Create an example application that uses the Runnable interface. 13. [10 marks] Can Abstract Class have constructors? Explain. Can interfaces have constructors? Explain. 14. [10 marks] What is recursion? How does recursion differ from loops?
Powered by