Name of University: Lovely Professional University
Name of Subject: Object-Oriented Programming
Course code: CSE211
Year of Examination: 2012
Semester Details: 2nd year B.Tech (Computer Science)
Course: B.tech (Computer Science)
Time : 3 hours
Max marks: 100
Here is the question paper:
B.Tech (II Yr)
End-Term Examination
CSE211 : Computer Architecture
Time: 3 hours
Maximum Marks: 100
Question 1.
(a) What is a global variable ? Explain two major problems that may occur due to global variables. (5)
(b) What is inheritance ? Explain two benefits of inheritance, with an example of each. (5)
(c) "One object in Java can be assigned as reference to another object of the same type." To explain this concept write a complete Java program and explain how a reference object works. (5)
(d) What is a constructor ? Write a Java program to explain how super class constructors are called in their subclasses. (5)
(e) What is multithreading ? Explain this with an example of how interthread communication takes place in Java. (5)
(f) Explaln how a string class object can be created using an existing String Buffer object. Also, explain how can you find the location of the last occurrence of a in the string "Java Programming".
(g) What is a checkbox ? How would you put checkboxes on an applet ? Explain how checkbox group is created in Java. (5)
(h) What is a datagram ? Explain how objects of the class Datagram Packet can be created. (5)
Question 2.
(a) What is an instance variable ? Explain how an instance variable of a class can have different value for each object of that class. (5)
(b) What is encapsulation ? Explain how encapsulation provides modularity and information hiding. (5)
(c) What is a URL connection ? Write a Java program to explain the processes of reading from and writing to a URL. (5)
(d) What is a language paradigm ? Explain two basic features of an object oriented paradigm. (5)
Question 3.
(a) List four differences between a Java applications program and Java applet program, with an example of each type of program. (8)
(b) Find the errors in the following Java program, and correct them. (6)
public class My_String
{
public vold main(string)
{ String str = "Java Programming"
Str.reverse()
System.out.println("Capacity:" + str.capacity())
}
}
(c) Write a program in Java which creates a file reference and finds the following :
(i) Path of the file
(ii) Whether file exists or not
(iii) Whether the file is writable or not
(iv) Size of the file.
Question 4.
(a) What is multithreaded programming ? Explain how threads are created in Java. Explain the need lot thread synchronization, with an example. (10)
(b) What is a package ? Explain, with an example, how name conflicts are resolved during package import. (4)
(c) Write a program to explain how parameters are passed in an applet Program. (6)
Question 5.
(a) What is a container ? Explain how components are added to a container. What is a default layout of an applet ? How can you change it ? (5)
(b) What is a bitwise operator ? If i is int i = 32, what will the value of i be after (5)
(i) i = < < < 3
(ii) i = i + i < < < 2 ?
(c) What is JDBC? Explain how SQL statements are written and executed in Java. (5)
(d) What is an exception? write an exception subclass which throws an exception if the variable age passed as argument to a method and the value of age is less than 20. (5)