[go: up one dir, main page]

0% found this document useful (0 votes)
65 views6 pages

Question Bank

The document contains a question bank with multiple choice and descriptive questions related to Object Oriented Programming using Java across 5 units. The questions cover topics like data types, operators, classes, inheritance, polymorphism, exceptions, multithreading, applets etc. and are divided into 2 parts with varying marks for each question.

Uploaded by

Mamata swain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views6 pages

Question Bank

The document contains a question bank with multiple choice and descriptive questions related to Object Oriented Programming using Java across 5 units. The questions cover topics like data types, operators, classes, inheritance, polymorphism, exceptions, multithreading, applets etc. and are divided into 2 parts with varying marks for each question.

Uploaded by

Mamata swain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

GITA AUTONOMOUS COLLEGE, BHUBANESWAR

QUESTION BANK
Sem: 3rd Semester
Branch: CSE, CSE-AI, CSE-DS, CST, CSIT
Sub: Object Oriented Programing using JAVA

PART-I
Unit-1 Mark BL CO PO
1) What gives java its “write once , run anywhere ” nature ? 2
2) Give an example of operator overloading in java 2
3) Pointers are eliminated from java because ________. 2
a) Pointer lead to confusion for a programmer
b) Pointers may crash a program easily
c)Pointers break security
d) All of the above
4) Assume double[][] x=new double[4][5], what are x.length and x[2].length ? 2
5) What are the default values for data field of a boolean type and object type? 2
6) What do you mean my portability of a program? Is java language portable? If 2
yes, Justify your answer.
7) Define Wrapper class. 2
8) Write the condition in which OUTPUT will be ELSE ? Justify your answer 2
public void foo( boolean a, boolean b)
{
if( a )
{
System.out.println("A"); /* Line 5 */
}
else if(a && b) /* Line 7 */
{
System.out.println( "A && B");
}
else /* Line 11 */
{
if ( !b )
{
System.out.println( "notB") ;
}
else
{
System.out.println( "ELSE" ) ;
}
}
}

9) What is a static method? 2


10) What will be the output 2
class Test{
public static void main(String[] args){
int x=(int )128.75;
byte a =(byte) x;
System.out.println(a);2
}2
}2
Unit-2
1) What do you mean by a constructor? When it is being called? 2
2) Explain the use of the keyword ‘this’. 2
3) What is inheritance? Why it is used by the programmers? 2
4) Explain widening and narrowing of primitive(basic) datatypes. 2
5) Write different types of inheritance. 2
6) What is a static block? When it is being called? 2
7) What is an innerclass? Write the syntax of creating an object of innerclass, 2
outside itsouterclass.

8) Explain method overriding. 2


9) Why Java does not support multiple inheritance? Then, how multiple 2
inheritance is implemented in Java.

10) Design a class to overload a function volume() as follows; 2


a. double volume(double r) – with radius ‘r’ as an argument,
returns the volume of sphere using the formula : v = 4/3 x
22/7 x r3.
b. double volume(double h, double r)- with height ‘h’ and radius
‘r’ as the arguments, returns the volume of a cuboid using the
formula: v = 22/7 x r2 x h.

Unit-3
1) Define an interface? 2
2) What is Abstraction in Java? 2
3) Write difference between String and StringBuffer. 2
4) Explain about Public and Private access specifiers. 2
5) What are the types of Exceptions? 2
6) Why abstract class has constructor even though you cannot create object? 2
7) Can I import the same package/class twice? Will the JVM load the package twice 2
at runtime?
8) What are the practical benefits, if any, of importing a specific class rather than 2
an entire package (e.g. import Java.net.* versus import Java.net.Socket) ?
9) Can a source file contain more than one class declaration? 2
10) What are the ways to compare string? 2
Unit-4
1) What is multithreading? 2
2) What are advantages of multithreading programming. 2
3) What is thread synchronization? 2
4) Write differences between sleep () and wait() methods . 2
5) Explain setPriority() and getPriotity() methods of Thread class. 2
6) Name the exception raised while invoking sleep() method. 2
7) What are the standard streams are available in Java? 2
8) What do you mean by Byte stream? Write name of two classes that support byte 2
stream.
9) What do you know by Character stream in Java? Write the name of two classes 2
that supports Character stream.
10) What do know by serialization in Java.
Unit-5 2
1) What is an applet program? 2
2) What is the difference between an Applet and a Java Application? 2
3) What is an event in java? 2
4) Explain Button class with example. 2
5) What is the use of paint() method in awt? 2
6) What is the need of Adapter classes for event handling? 2
7) What is the difference between TextField and TextArea components? 2

PART-II
Unit-1 Mark BL PO CO
1) Write a program in java to take an array and calculate sum of even and 4
multiplication of odd numbers in the array.
2) What is type casting ? Explain different types of type casting with 4
example .
3) Briefly explain various features of java. 4
4) Write a java program to print prime number up to 50. 4
5) Write program to swap value of two variables by accepting them using 4
Scanner class.
6) Write java program to input a temperature in Fahrenheit and convert it to 4
Celsius using the following conversion formula. C=(F-32)/1.8.
7) Write a java program to create and display a unit matrix of size 4. 4

Unit-2
1) Create a class for product with private instance variablesproduct_id,name,price. 4
Create two product objects. Using parameterized constructor initialize the
instance variables and display them using another method.
2) Write a program to differentiate the feature of static variable and instance 4
variable.
3) Create an object for complex numbers with real and imaginary part. Using 4
separate methods initialize and display the complex objects. Define another
method to perform the addition of two complex numbers and will return the
result complex object.
4) What is method overriding? Explain with a program. 4

5) With an example, explain widening and narrowing of referenced datatype(class 4


type) achieved in inheritance.
6) Write a program to show multilevel inheritance. 4
7) Write short notes on Polymorphism. 4

Unit-3
1) Difference between Abstract class and Interface. 4

2) What is the final keyword in Java? 4

3) Difference between final, finally and finalize. 4

4) Explain about Exception Propagation. 4

5) What are the Exception handling keywords in Java? 4


6) What are the advantages of Exception handling? 4
7) What is a Java package and how is it used? 4
Unit-4
1) What do you know by a thread in java?.Explain how can a thread is created in 4
java.
2) Write the hierarchy of all stream classes in java. 4
3) Explain the classes and methods used for writing and reading objects into a file. 4
4) Explain with an example how to check end of binary file in java. 4
5) Write a multithreaded java program to display contents of two arrays of two 4
threads simultaneously.
Unit-5
1) Write differences between applet and application programs. 4

2) What are differences between AWT and SWING components? 4

3) Write an applet program to display your name, branch and roll number 4
in applet window.

4) What do you know by wrapper class in java? Write the name of all 4
wrapper classes corresponding to all primitive types.

5) Explain the event delegation model used in java for event handling. 4

PART-III
Unit-1 Mark BL PO CO
1) a) a) Write a program to input 10 integers into an array and print the second 10
highest number ?
b) b) Write a program to reverse an input number and check whether or not
it is a palindrome ( The number is same as its reverse )
2) a) a) Write a program to print the sum of the following series. 10

S= 1! + 2! + 3 ! +…….+N! (accept value of N as input)


N!= 1 * 2*3*4*…*N
b) Write a program to accept two numbers as command line arguments
and display their HCF
3) a) a) Write a program to input 9 elements each into two 2-D 10
arrays(matrices) and print whether they are equal or not
b) b) Write a program to input 9 elements into 3x3 matrix. Print the elements
of both left diagonal and right diagonal.
Unit-2
1) a) With a suitable example, explain constructor overloading. 10
b) Explain the four types of access specifiers used in java. Demonstrate with an
appropriate program.

2) WAP to store ‘ n ’ number of Employee objects in an array. Each object contains 10


private instance variables ename, id, basic_salary, gender and allowance.
Initialize and display the array using separate methods, don't take input for
allowance. Allowance is 10% of basic_salary for male and 11% for female.
Implement another static method which will return the name of the employee,
who is getting highest salary.
3) a) Create a class Student with attributes roll, name, age, mark. Create three 10
objects of Student class. Using methods input and display all the objects. Define
a static method which will return the sum of marks of these three students.
b) Explain three uses of ‘super’ keyword. Write a program where the parent class
(super class) and child class (sub class) are having parameterized constructors.

4) a) What is super keyword and why it is used? Write a java program to find out 10
cost, weight and volume of a box using multilevel inheritance and use
super keyword at proper places?

b) Write a program in Java to read a file and count the number of occurrence of
digit 5. Supply the file name as command line argument.
Unit-3
1) a) What is the difference between exception and error? 10
b) Explain try, catch, throw, throws and finally keyword with example?

2) a) Explain the statement “A string is a static and immutable object”. 10


b) Write a program to input a sentence and display in short form.
e.g. INPUT: Mangoes Are Delivered At Midnight
OUTPUT: M.A.D.A.M

3) a) What are the advantages of packages in Java? What is a standard package in 10


Java?
b) Write a program to accept three numbers as command line argument. Print
the highest number.
Unit-4
1) a) Write a Java program to copy contents of one file to another. 10

b) What is thread synchronization? Explain with example how thread


synchronization
2) a) Explain the concept of Auto Boxing and Auto Unboxing with suitable 10
example.

b) Write a Java program to implement thread Synchronization

Unit-5
1) Explain the life cycle of an applet with state – transition diagram. Also 10
discuss all 5 methods responsible for maintaining life cycle of an applet.

2) a. Write a Java program using awt components for displaying a login 10


form.

b. What do you know by event delegation model? Explain all


components of an event delegation model with example.

3) .What do you know by layout manager? Explain FlowLayout,


BorderLayout and GridLayout with example.

You might also like