0% found this document useful (0 votes)
3 views

Java Questions

The document contains examination instructions and questions related to Java programming, covering topics such as features of Java, constructors, inheritance, exception handling, and applet life cycle. It includes multiple sections where students are required to attempt various questions, with marks allocated for each. The format emphasizes the importance of clarity in answers and the use of examples where applicable.

Uploaded by

atharvanichat420
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Java Questions

The document contains examination instructions and questions related to Java programming, covering topics such as features of Java, constructors, inheritance, exception handling, and applet life cycle. It includes multiple sections where students are required to attempt various questions, with marks allocated for each. The format emphasizes the importance of clarity in answers and the use of examples where applicable.

Uploaded by

atharvanichat420
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

22412

21819
3 Hours / 70 Marks Seat No.

Instructions – (1) All Questions are Compulsory.


(2) Answer each next main Question on a new page.
(3) Figures to the right indicate full marks.
(4) Assume suitable data, if necessary.
(5) Use of Non-programmable Electronic Pocket
Calculator is permissible.
(6) Mobile Phone, Pager and any other Electronic
Communication devices are not permissible in
Examination Hall.

Marks

1. Attempt any FIVE of the following: 10


a) List any eight features of Java.
b) State use of finalize( ) method with its syntax.
c) Name the wrapper class methods for the following:
(i) To convert string objects to primitive int.
(ii) To convert primitive int to string objects.
d) List the types of inheritances in Java.
e) Write the syntax of try-catch-finally blocks.
f) Give the syntax of < param > tag to pass parameters to an
applet.
g) Define stream class. List its types.

P.T.O.
22412 [2]
Marks
2. Attempt any THREE of the following: 12
a) Explain the concept of platform independence and portability
with respect to Java language.
b) Explain the types of constructors in Java with suitable example.
c) Explain the two ways of creating threads in Java.
d) Distinguish between Input stream class and output stream
class.

3. Attempt any THREE of the following: 12


a) Define a class student with int id and string name as data
members and a method void SetData ( ). Accept and display
the data for five students.
b) Explain dynamic method dispatch in Java with suitable
example.
c) Describe the use of following methods:
(i) Drawoval ( )
(ii) getFont ( )
(iii) drawRect ( )
(iv) getFamily ( )
d) Write a program to count number of words from a text file
using stream classes.

4. Attempt any THREE of the following: 12


a) Describe instance Of and dot ( . ) operators in Java with
suitable example.
b) Explain the four access specifiers in Java.
c) Differentiate between method overloading and method
overriding.
d) Differentiate between Java Applet and Java Application ( any
four points)
e) Write a program to copy content of one file to another file.
22412 [3]
Marks
5. Attempt any TWO of the following: 12
a) Describe the use of any methods of vector class with their
syntax.
b) Explain the concept of Dynamic method dispatch with suitable
example.
c) Write a program to create two threads. One thread will
display the numbers from 1 to 50 (ascending order) and other
thread will display numbers from 50 to 1 (descending order).

6. Attempt any TWO of the following: 12


a) Explain the command line arguments with suitable example.
b) Write a program to input name and salary of employee and
throw user defined exception if entered salary is negative.
c) Describe the applet life cycle in detail.
22412
11920
3 Hours / 70 Marks Seat No.

Instructions – (1) All Questions are Compulsory.


(2) Answer each next main Question on a new page.
(3) Illustrate your answers with neat sketches wherever
necessary.
(4) Figures to the right indicate full marks.
(5) Assume suitable data, if necessary.
(6) Mobile Phone, Pager and any other Electronic
Communication devices are not permissible in
Examination Hall.

Marks

1. Attempt any FIVE of the following: 10


a) Define constructor. List its types.
b) Define class and object.
c) List the methods of File Input Stream Class.
d) Define error. List types of error.
e) List any four Java API packages.
f) Define array. List its types.
g) List access specifiers in Java.

P.T.O.
22412 [2]
Marks
2. Attempt any THREE of the following: 12
a) Differentiate between String and String Buffer.
b) Define a class circle having data members Pi and radius.
Initialize and display values of data members also calculate
area of circle and display it.
c) Define exception. State built-in exceptions.
d) Write a syntax and example of
(i) drawRect( )
(ii) drawoval( )

3. Attempt any THREE of the following: 12


a) Explain the following classes.
(i) Byte Stream Class
(ii) Character Stream Class
b) Explain life cycle of Applet.
c) Differentiate between class and interfaces.
d) Define type casting. Explain its types with syntax and
example.

4. Attempt any THREE of the following: 12


a) Explain life cycle of thread.
b) Describe final variable and final method.
c) Explain any two logical operators in Java with example.
d) Differentiate between array and vector.
e) List any four methods of string class and state the use of each.
22412 [3]
Marks
5. Attempt any TWO of the following: 12
a) Write a program to create vector with five elements as
(5, 15, 25, 35, 45). Insert new element at 2nd position.
Remove 1st and 4th element from vector.
b) Define packages. How to create user defined package?
Explain with example.
c) Write a program to create two threads one thread will print
even no. between 1 to 50 and other will print odd number
between 1 to 50.

6. Attempt any TWO of the following: 12


a) Explain how to pass parameter to an applet? Write an
applet to accept username in the form of parameter and
print “Hello <username>”.
b) Write a program to perform following task.
(i) Create a text file and store data in it.
(ii) Count number of lines and words in that file.
c) Implement the following inheritance.

Interface : Salary Class : Employee


Basic_Salary Name, age
Basic_Sal ( ) Display ( )

Class: Gross_Salary
TA, DA, HRA
Total_Sal ( )

22412
21222
3 Hours / 70 Marks Seat No.
15 minutes extra for each hour

Instructions – (1) All Questions are Compulsory.


(2) Answer each next main Question on a new page.
(3) Illustrate your answers with neat sketches wherever
necessary.
(4) Figures to the right indicate full marks.
(5) Assume suitable data, if necessary.
(6) Mobile Phone, Pager and any other Electronic
Communication devices are not permissible in
Examination Hall.
Marks

1. Attempt any FIVE of the following: 10


a) Enlist the logical operators in Java.
b) Give the syntax and example for the following functions
i) min ( )
ii) Sqrt ( )
c) Define the interface in Java.
d) Enlist any four inbuilt packages in Java.
e) Explain any two methods of File Class.
f) Write syntax of elipse.
g) Enlist any four compile time errors.

P.T.O.
22412 [2]
Marks
2. Attempt any THREE of the following: 12
a) Explain any four features of Java.
b) Write a Java program to copy the content of one file into
another.
c) Write the difference between vectors and arrays. (any four
points)
d) Explain exception handling mechanism. w.r.t. try, catch, throw
and finally.

3. Attempt any THREE of the following: 12


a) Write a Java program to find out the even numbers from
1 to 100 using for loop.
b) Explain any four visibility controls in Java.
c) Explain single and multilevel inheritance with proper example.
d) Write a java applet to display the following output in Red
color. Refer Fig No. 1.

Fig No. 1.

4. Attempt any THREE of the following: 12


a) Explain switch case and conditional operator in java with
suitable example.
b) Draw and explain life cycle of Thread.
c) Write a java program to sort an 1-d array in ascending order
using bubble-sort.
d) Explain how to create a package and how to import it.
e) Explain
i) drawLine
ii) drawOval
iii) drawRect
iv) drawArc
22412 [3]
Marks
5. Attempt any TWO of the following: 12
a) How to create user defined package in Java. Explain with
an suitable example.
b) Write a Java program in which thread A will display the
even numbers between 1 to 50 and thread B will display
the odd numbers between 1 to 50. After 3 iterations thread
A should go to sleep for 500 ms.
c) What is constructor? List types of constructor. Explain
paramaterized constructor with suitable example.

6. Attempt any TWO of the following: 12


a) Write a Java program to count the number of words from a
text file using stream classes.
b) Explain the difference between string class and string buffer
class.
Explain any four methods of string class.
c) Write a Java applet to draw a bar chart for the following
values.
Year 2011 2012 2013 2014
Turnover
110 120 170 160
(Rs. crores)
22412
12223
3 Hours / 70 Marks Seat No.

Instructions – (1) All Questions are Compulsory.


(2) Answer each next main Question on a new page.
(3) Illustrate your answers with neat sketches wherever
necessary.
(4) Figures to the right indicate full marks.
(5) Assume suitable data, if necessary.
(6) Mobile Phone, Pager and any other Electronic
Communication devices are not permissible in
Examination Hall.

Marks

1. Attempt any FIVE of the following : 10


a) State any four relational operators and their use.
b) Enlist access specifiers in Java.
c) Explain constructor with suitable example.
d) List the types of inheritance which is supported by java.
e) Define thread. Mention 2 ways to create thread.
f) Distinguish between Java applications and Java Applet
(Any two points)
g) Draw the hierarchy of stream classes.

P.T.O.
22412 [2]
Marks
2. Attempt any THREE of the following : 12
a) Write a program to check whether the given number is prime
or not.
b) Define a class employee with data members ‘empid’, ‘name’
and ‘salary’. Accept data for three objects and display it.
c) Describe Life cycle of thread with suitable diagram.
d) Write a program to read a file (Use character stream)

3. Attempt any THREE of the following : 12


a) Write a program to find reverse of a number.
b) State the use of final keyword with respect to inheritance.
c) Give the usage of following methods
i) drawPolygon ( )
ii) DrawOval ( )
iii) drawLine ( )
iv) drawArc ( )
d) Write any four methods of file class with their use.

4. Attempt any THREE of the following : 12


a) Write all primitive data types available in Java with their
storage sizes in bytes.
b) Write a program to add 2 integer, 2 string and 2 float values
in a vector. Remove the element specified by the user and
display the list.
c) Develop a program to create a class ‘Book’ having data
members ‘author’, ‘title’ and ‘price’. Derive a class ‘BookInfo’
having data member ‘stockposition’ and method to initialize
and display the information for three objects.
d) Mention the steps to add applet to HTML file. Give sample
code.
e) Write a program to copy contents of one file to another.
22412 [3]
Marks
5. Attempt any TWO of the following : 12
a) Compare array and vector. Explain elementAT( ) and
addElement( ) methods.
b) Write a program to create a class ‘salary’ with data members
‘empid’, ‘name’ and ‘basicsalary’. Write an interface ‘Allowance’
which stores rates of calculation for da as 90% of basic salary,
hra as 10% of basic salary and pf as 8.33% of basic salary.
Include a method to calculate net salary and display it.
c) Define an exception called ‘No Match Exception’ that is
thrown when the passward accepted is not equal to ‘MSBTE’.
Write the program.

6. Attempt any TWO of the following : 12


a) Write a program to check whether the string provided by the
user is patindrome or not.
b) Define thread priority ? Write default priority values and the
methods to set and change them.
c) Design an applet to perform all arithmetic operations and
display the result by using labels. textboxes and buttons.
22412
22223
3 Hours / 70 Marks Seat No.

Instructions – (1) All Questions are Compulsory.


(2) Answer each next main Question on a new page.
(3) Illustrate your answers with neat sketches wherever
necessary.
(4) Figures to the right indicate full marks.
(5) Assume suitable data, if necessary.
(6) Mobile Phone, Pager and any other Electronic
Communication devices are not permissible in
Examination Hall.

Marks

1. Attempt any FIVE of the following: 10


a) Define the terms with example
i) Class
ii) Object
b) Enlist any two access specifier with syntax.
c) Give a syntax to create a package and accessing package in
java
d) Give a syntax of following thread method
i) Notify ( )
ii) Sleep ( )
e) Give a syntax of 〈param〉 tag to pass parameters to an applet.
f) Define stream class and list types of stream class.
g) Give use of garbage collection in java.

P.T.O.
22412 [2]
Marks
2. Attempt any THREE of the following: 12
a) Describe type casting in java with example.
b) Differentiate between string and string buffer class
(any four points)
c) Write a program to create a user defined exception in java.
d) Write a program for reading and writing character to and from
the given files using character stream classes.

3. Attempt any THREE of the following: 12


a) Write a program to print all the Armstrong numbers from
0 to 999.
b) Explain the applet life cycle with neat diagram.
c) Describe the package in java with suitable example.
d) Enlist types of Byte stream class and describe input stream
class and output stream class.

4. Attempt any THREE of the following: 12


a) Describe any four features of java.
b) Explain any four methods of vector class with example.
c) Describe interface in java with suitable example.
d) Write an applet program for following graphics method.
i) Drawoval ( )
ii) Drawline ( )
e) Enlist any four methods of file input stream class and give
syntax of any two methods.
22412 [3]
Marks
5. Attempt any TWO of the following: 12
a) Write a program to copy all elements of one array into
another array.
b) Write a program to implement the following inheritance.
Refer Fig. No. 1.

Fig. No. 1
c) Write a program to print even and odd number using two
threads with delay of 1000ms after each number.

6. Attempt any TWO of the following: 12


a) Explain thread life cycle with neat diagram.
b) Write a program to generate following output using
drawline ( ) method. Refer Fig. No. 2.

Fig. No. 2
c) Explain constructor with its type. Give an example of
parameterized constructor.
22412
23124
3 Hours / 70 Marks Seat No.

Instructions – (1) All Questions are Compulsory.


(2) Answer each next main Question on a new page.
(3) Illustrate your answers with neat sketches wherever
necessary.
(4) Figures to the right indicate full marks.
(5) Assume suitable data, if necessary.
(6) Mobile Phone, Pager and any other Electronic
Communication devices are not permissible in
Examination Hall.

Marks

1. Attempt any FIVE of the following : 10


a) Enlist any two logical operators and two bitwise operators.
b) Define constructor.
c) Write down the syntax of array declaration, initialization.
d) List out different ways to access package from another package.
e) Differentiate between starting thread with run (  ) method and
start (  ) method.
f) State the classes that can an applet extend.
g) Give syntax to open a file using Inputstream class.

P.T.O.
22412 [2]
Marks
2. Attempt any THREE of the following : 12
a) Write a program to display ASCII value of a number 9.
b) Write a program to sort the elements of an array in ascending
order.
c) Define Thread. Draw life cycle of Thread.
d) Write a program to read a file and then count number
of words.

3. Attempt any THREE of the following : 12


a) Write a program which displays functioning of ATM machine,
(Hint : Withdraw, Deposit, Check Balance and Exit)
b) Differentiate between method overloading and method overriding.
c) Explain applet life cycle in detail.
d) Differentiate between Byte Stream Class and Character Stream
Class. (Any four points)

4. Attempt any THREE of the following : 12


a) Explain implicit and explicit type conversion with example
in detail.
b) Write a program to show the use of copy constructor.
c) Write a program to show the Hierarchical inheritance.
d) Explain any four font methods with example.
e) Write a program to append content of one file into
another file.
22412 [3]
Marks
5. Attempt any TWO of the following : 12
a) Explain vector with the help of example. Explain any 3 methods
of vector class.
b) Develop and Interest Interface which contains Simple Interest
and Compound Interest methods and static final field of rate
25%. Write a class to implement those methods.
c) Write a program that throws an exception called
“NoMatchException” when a string is not equal to “India”.

6. Attempt any TWO of the following : 12


a) Write a program to print the sum, difference and product of
two complex numbers by creating a class named “Complex”
with separate methods for each operation whose real and
imaginary parts are entered by user.
b) i) Explain Errors and its types in detail.
ii) Explain thread methods to set and get priority.
c) Write a program to draw a chessboard in Java Applet.
22412
23242
3 Hours / 70 Marks Seat No.

Instructions – (1) All Questions are Compulsory.


(2) Answer each next main Question on a new page.
(3) Illustrate your answers with neat sketches wherever
necessary.
(4) Figures to the right indicate full marks.
(5) Assume suitable data, if necessary.
(6) Mobile Phone, Pager and any other Electronic
Communication devices are not permissible in
Examination Hall.
Marks

1. Attempt any FIVE of the following: 10


a) State the significance of Java Virtual Machine (JVM) in the Java
programming environment.
b) Define array. List its types.
c) State use of finalize( ) method with its syntax.
d) Define the interface in Java. Write the syntax.
e) Define thread. Mention 2 ways to create thread.
f) Write syntax of draw Rect( ).
g) Give the use of <PARAM> tag in applet.

2. Attempt any THREE of the following: 12


a) Explain the concept of platform independence in Java and discuss
how it is achieved. Give example to illustrate the concept.
b) What happens if you don't define any constructor in a class?
Can you still create objects of that class? Explain with example.
c) Write a Java program in which thread A will display the even
numbers between 1 to 50 and thread B will display the odd
numbers between 1 to 50. After 3 iterations thread A should
go to sleep for 500 ms.
d) Explain multilevel inheritance with example. P.T.O.
22412 [2]
Marks
3. Attempt any THREE of the following: 12
a) Define a class employee with data members ‘empid’, ‘name’ and
‘salary’. Accept data for three objects and display it.
b) How can the "super" keyword be used in inheritance? Give an
example to demonstrate its usage.
c) Explain the following with syntax:
i) drawLine
ii) drawOval
iii) drawArc
iv) drawString
d) What is the concept of streams in Java? How do streams facilitate
input and output operations?

4. Attempt any THREE of the following: 12


a) Explain any two logical operators in Java with example.
b) What is constructor? List types of constructor. Explain
parameterized constructor with suitable example.
c) Implement the following inheritance. Refer Fig. No. 01.

Fig. No. 01
22412 [3]
Marks
d) Explain Life Cycle of the applet with neat diagram.
e) Create a new test file named ''data.txt'' using the File class.
Write a program to count number of words of "data.txt" using
stream classes.

5. Attempt any TWO of the following: 12


a) Explain the concept of argument passing and the usage of 'this'
keyword in Java give example to illustrate their usage and benefits.
b) Explain the concept of packages in Java and their significance in
software development. Write an example to illustrate the usage and
benefits of using packages.
c) Explain the concept of exception handling in Java and its
importance in robust programming. Provide an example to illustrate
the implementation and benefits of exception handling.

6. Attempt any TWO of the following: 12


a) Write a program to define class Employee with members as id
and salary. Accept data for five employees and display details of
employees getting highest salary.
b) Define exception called ‘No Match Exception’ that is thrown
when the password accepted is not equal to ‘MSBTE’. Write the
program.
c) Write a program to design an Applet showing three concentric
circles filled with three different colors.
22412
12425
03 Hours / 70 Marks Seat No.

Instructions – (1) All Questions are Compulsory.


(2) Answer each next main Question on a new page.
(3) Illustrate your answers with neat sketches wherever
necessary.
(4) Figures to the right indicate full marks.
(5) Assume suitable data, if necessary.
(6) Mobile Phone, Pager and any other Electronic
Communication devices are not permissible in
Examination Hall.

Marks

1. Attempt any FIVE of the following : 10


a) Enlist any four features of java.
b) Write the use of ‘this’ keyword.
c) Write the use of super keyword.
d) Explain the use of throw and throws.
e) Enlist the life cycle methods of Applet.
f) Give two methods of file class.
g) Write the use of <PARAM> tag in an applet.

P.T.O.
22412 [2]
Marks
2. Attempt any THREE of the following : 12
a) Write a program using sqrt( ) and pow( ) to calculate the square
root and power of given number.
b) Write a program to accept four numbers from user using
command line arguments and print the smallest number.
c) Explain two ways of creating threads in java with suitable
example.
d) Give the usage of following :
i) set Color ( )
ii) get Color ( )
iii) set Foreground ( )
iv) set Background

3. Attempt any THREE of the following : 12


a) Write a java program to copy the contents of one file
into another.
b) Write a program to create user defined exception “MIN-BAL”.
Throw the exception when balance in account is below
500 rupees.
c) Define a class employee having data members as emp_id, name
and salary. Accept and display the data for five employees.
d) Write the use of ‘Final’ key word with suitable example.

4. Attempt any THREE of the following : 12


a) Enlist and explain four access specifiers in java.
b) Write a program to demonstrate the use of conditional operator
and switch case statement.
c) Explain how to create a package and import it with suitable
example.
d) Draw and explain life cycle of thread.
e) Explain garbage collection mechanism in java with suitable
example.
22412 [3]
Marks
5. Attempt any TWO of the following : 12
a) Explain dynamic method dispatch mechanism with suitable
example.
b) Write a program to check whether entered number is Armstrong
number or not.
c) Design an Applet using <PARAM> tag to accept the two
numbers and perform arithmetic operations.

6. Attempt any TWO of the following : 12


a) Explain life cycle of an Applet with suitable example.
b) Write a program to create two threads. One thread will display
the odd numbers from 1 to 50 and the other thread will
display the even numbers.
c) Describe the use of any methods of vector class with their
syntax. (Any six methods)

You might also like