WBUT or West Bengal university of technology is conducted MCA along with various technical courses. According to their MCA syllabus, students learn JAVA in the 5th semester. We are trying to give some guidance to the WBUT students by previous year solved papers. Here we discuss the Java paper of 2009.
Time Allotted: 3 HoursFull Marks: 70
The figures in the margin indicate full marks. Candidates are required to give their answers in their own words as far as practicable.
1. Choose the correct alternatives for the following : 10 × 1 = 10
i) if (check(storeNum) ! = null) { } Referring to the above, what datatype could be returned by method check()?
a) boolean b) string
c) char d) byte.
ii) int j;
for(int i=0; i<14;i++)
{
if(i<10)
{
j = 2 + i;
}
System.out.println ("j:" +j+ " i:"+i);
}
What is wrong with the above code ?
a) Integer "j" is not initialized b) nothing
c) you cannot declare integer i inside the for-loop declaration
d) you cannot print integer values without converting them to strings.
iii) Which access modifier is used to restrict the methods scope to itself and still allows other classes to subclass that class ?
a) private b) final c) protected d) final.
iv) What is the output of the following program ?
public class Trial
{
int x;
public static void main(String args[ ])
{
x = 8;
System.out.print("The value of x is" + x);
}
}
a) The program prints The value of x is 8
b) The program prints The value of x is 0
c) The program will not compile
d) None of these.
v) What do the ‘public’ and ‘private’ keywords relate to?
a) typing
b) garbage collection
c) polymorphism
d) access restriction.
vi) Which of the following is True?
a) A class that is abstract must be containing all abstract methods.
b) The final keyword indicates that the body of a method is to be found elsewhere. The code is written in non-Java language, typically in C/C++.
c) A static variable indicates there is only one copy of that variable.
d) A method defined as private indicates that it is accessible to all other classes in the same package.
vii) An interface can define only
a) abstract class b) final field
c) abstract method d) abstract method and final field.
viii) Under which circumstances will a thread stop?
a) The run() method that the thread is executing ends.
b) The call to the start( ) method of the thread object returns.
c) The suspend() method is called on the thread object.
d) The wait( ) method is called on the thread object.
ix) Dynamic method dispatcher is useful for
a) resolving method overriding b) resolving multilevel inheritance
c) resolving multiple inheritance anomaly d) none of these.
x) Which of the following statements is true regarding constructors?
a) All classes must define a constructor.
b) A constructor can be declared private.
c) A constructor can return a value.
d) A constructor must initialize all the fields of a class.
Answer any three of the following. 3 × 5 = 15
2. What is the difference between an Interface and an Abstract class? What is the purpose of garbage collection in Java and when is it used? 2 + 3
Ans.
3. What is encapsulation? Explain how encapsulation provides modularity and information hiding?2 + 3
Ans.
4. Discuss that steps involved in developing and running a local applet. 5
Ans.
5. What are the main differences between Java and C the +? 5
Ans.
6. What do you mean by the interface? Write the differences between an interface and an abstract class.5
Answer any three of the following. 3 × 15 = 45
7. What is an object oriented paradigm ? Explain two differences between the object oriented paradigm of programming languages and the structured paradigm of programming languages. Suppose you write a Java program
Main.java as :
public class Main
{
public static void main ( String s [ ] )
{
System.out.println(“Best of luck”);
}
}
Is really this code platform ( Operating System ) independent? Justify your answer. If not, explain how the statement justifies “JAVA is called platform independent”. Explain all words in the statement: “public static void main (String [ ] s)” 2 + 3 + 3 + 3 + 4
Ans.
8. What is multithreading ? Explain the advantages of multithread programs. Write a program in Java to explain how different priorities can be assigned to different threads. What is an exception ? Explain, with an example, how exceptions are handled in Java. 2 + 3 + 5 + 2 + 3
Ans.
9. Describe the different stages in the lifecycle of an applet. Distinguish between init ( ) and start ( ) methods. What is the difference between checked and unchecked exceptions ? Give an example where the interface can be used to support multiple inheritances. Develop a Java program for the example. 4 + 3 + 3 + 5
Ans.
10. a) Describe the complete life-cycle of a thread. What is synchronization? When is it used? 5 + 3 + 2
Ans.
b) Write a small program which will synchronize among two threads. What is thread priority? 3 + 2
Ans.
11. Write short notes on any three of the following : 3 × 5
a) Runtime polymorphism in Java
b) JVM
c) Inter-thread communication
d) Package
e) Final, finally and finalize keyword.