Oops
Oops
___________
Q.1 (a) How java supports platform independency? What is the role of JVM in it? 03
(b) Write a program which displays first n prime number? Where is n provided 04
by user as command line argument?
(c) Write a program which declare integer array of 10 elements? Initialize array 07
and define following methods with the specified header:
(i) public static int add(int [] array) print addition of all element of array.
(ii) public static int max(int [] array) print maximum element of array.
(ii) public static int search(int [] array, int key) search element key in array
and return index of it. If element is not found method will return -1.
Q.2 (a) Describe the relationship between an object and its defining class? 03
(b) Analyze following code. Validate and explain output of code. If any error 04
exists, indicate portion. Suggest code to eliminate error:
public class Circle {
private double radius;
public static void main(String args[]){
Circle c1=new Circle(2);
System.out.println("Area "+c1.getArea());
B b1=new B(2, 2);
System.out.println("Area "+b1.getArea());
}
public Circle(double radius) {
radius = radius;
}
public double getRadius() {
return radius;
}
public double getArea() {
return radius * radius * Math.PI;
}
}
1
OR
(c) Answer in brief(within two lines): 07
(i) If a method defined in a subclass has the same signature as a method in its
superclass with the
same return type, is the method overridden or overloaded?
(ii) How do you invoke an overridden superclass method from a subclass?
(iii) What is the purpose of "this" keyword?
(iv) Differentiate between following statements:
int a=3;
Integer b=new Integer(3);
(v) Which java keyword is used to prevent inheritance (prevent class to be
extended)?
(vi) Can we create reference of interface. If we can create, then what is the
use of it?
(vii) What is the difference between a String in Java and String in C/C++?
Q.4 (a) Write a program to find out whether the given number is palindrome or not? 03
(b) Outline the use of throw in exception handling with example. 04
(c) Give Definitions: static, finalize, final 07
OR
Q.4 (a) Elaborate the role of java garbage collector. 03
(b) State four similarities between Interfaces and Classes. 04
(c) Differentiate between ArrayList and LinkedList? Which list should you use 07
to insert and delete elements at the beginning of a list? What methods are in
LinkedList but not in ArrayList?
***********
3
Seat No.: ________ Enrolment No.___________
MARKS
Q.1 (a) What is the Java bytecode, and what is the extension of Java bytecode file? 03
Which software is needed to run Java bytecode?
(b) Describe syntax errors (compile errors), runtime errors, and logic errors by 04
giving suitable examples?
(c) Answer in brief (within 50 words): 07
I. Justify Java enables high performance.
II. Differentiate between while and do while loop?
III. How many times is the println statement executed?
for (int i = 0; i < 10; i++)
for (int j = 0; j < i; j++)
System.out.println(i * j);
IV. If the value of variable x is 1 then what will be returned by the
following expression:
x%2==0
Q.2 (a) What is the use of this keyword? How it is different from super keyword? 03
(b) (i) Given that Thing is a class, how many objects and how many reference 04
variables are created by the following code?
Thing item, stuff;
item = new Thing();
Thing entity = new Thing();
(ii) Examine following code. Write and justify output.
public class MyClass {
public static void main(String[] args) {
C c = new C();
System.out.println(c.max(12, 29));
}
}
class A {
int max(int x, int y) { if (x>y) return x; else return y; }
}
class B extends A{
int max(int x, int y) { return super.max(y, x) - 10; }
}
class C extends B {
int max(int x, int y) { return super.max(x+10, y+2); }
}
(c) Write a program that defines class named StopWatch. The class contains: 07
• Private data fields startTime and endTime with getter methods.
1
• no-arg constructor that initializes startTime with the current time.
• A method named start() that resets the startTime to the current time.
• A method named stop() that sets the endTime to the current time.
• A method named getElapsedTime() that returns the elapsed time for
the stopwatch in milliseconds.
• Declare object of StopWatch to demonstrate stop watch.
Hint: Use System.currentTimeMillis() to get current time in milliseconds.
OR
(c) Create a class called Employee that includes: 07
I. Three instance variables— id (type String), name (type String) and
monthly_salary (double).
II. A default constructor that initializes the three instance variables.
III. A setter and a getter method for each instance variable (for example
for id variable void setId(String id), String getId( )).
IV. displayEmployee() method for displaying employee details.
Write a driver class named EmployeeTest that demonstrates class Employee’s
capabilities. Create two Employee objects and display each object’s yearly
salary. Then give each Employee a 10% raise and display each Employee’s
yearly salary again.
1
Seat No.: ________ Enrolment No.___________
MARKS
Q.1 (a) Define object oriented concepts. 03
(b) What is the difference between the StringBuffer and StringBuilder 04
classes?
(c) Define constructor. How objects are constructed? Explain constructor 07
overloading with an example.
Q.2 (a) Explain about arrays, Type of arrays and arrays methods. 03
(b) Explain about Encapsulation, Abstraction. 04
(c) State the design hints for class and inheritance. 07
Also discuss the working and meaning of the “static” modifier with
suitable examples.
OR
(c) Explain in detail how inheritance and polymorphism are supported in 07
java with necessary examples.
Q.3 (a) Explain about different types of string methods. 03
(b) Write short notes on access specifiers and modifiers in java. 04
(c) What is an Exception? Explain the exception hierarchy. Explain how 07
to throw, catch and handle Exceptions.
OR
Q.3 (a) Explain about Final class, Fields, Methods. 03
(b) What is a Package? What are the benefits of using packages? Write 04
down the steps in creating a package and using it in a java program
with an example.
(c) Explain the concept of inner classes and explain the types of inner 07
classes with an example program.
Q.4 (a) What is Dynamic binding? Show with an example how dynamic 03
binding works.
(b) Write short notes about I/O stream classes. 04
(c) Explain the thread state, thread properties and thread synchronization. 07
OR
Q.4 (a) Explain the concept of finalization. 03
(b) What is reflection and how does it help to manipulate java code. 04
(c) Write a java program to implement the multiple inheritance concepts 07
for calculating area of circle and square.
Q.5 (a) Explain about callback 03
(b) Explain the interface with an example program. 04
(c) What is Generic programming and why is it needed? Explain with 07
example. List the limitations and restrictions of generic programming
1
OR
Q.5 (a) Explain about Proxy class, Interface and Methods. 03
(b) Explain about adapter classes and mouse events with an example. 04
(c) With a neat diagram explain the Model view controller design pattern 07
and list out the advantages and disadvantages of using it in designing
an application.
*************
2
Seat No.: ________ Enrolment No.___________
*************
2
Seat No.: ________ Enrolment No.___________
Q.1 (a) What is the difference between oop and procedural oriented language? 03
(b) Explain type-conversion in java. 04
(c) Explain class and object with respect to java. 07
*************
1
Seat No.: ________ Enrolment No.___________
MARKS
Q.1 (a) What are syntax errors (compile errors), runtime errors, and logic 03
errors?
(b) What is Type Casting? Explain widening and narrowing type 04
casting.
(c) Explain Data Types in detail with example. 07
1
Q.5 (a) Compare List and Set. 03
(b) Explain static variable and static method with example. 04
(c) Explain Thread Synchronization with example. 07
*************
2
Seat No.: ________ Enrolment No.___________
Q.3 (a) What is the final class? Why they are used? 03
(b) Write exception handling mechanisms in JAVA. 04
(c) Explain Overloading and Overriding with example. 07
OR
Q.3 (a) How can you create packages in Java? 03
(b) What is Inheritance? List out the different forms of Inheritance and 04
explain any one with example.
(c) Explain the words super, static, final and this with the help of an 07
example.