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

Java Questions According to Topics

The document covers fundamental concepts of Java, including features, JVM significance, classes, objects, constructors, operators, access specifiers, type casting, and platform independence. It also discusses keywords, core concepts, arrays, packages, inheritance, exception handling, threads, interfaces, applets, file handling, streams, strings, vectors, and various programming tasks. Each section includes definitions, explanations, examples, and programming exercises to illustrate the concepts.

Uploaded by

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

Java Questions According to Topics

The document covers fundamental concepts of Java, including features, JVM significance, classes, objects, constructors, operators, access specifiers, type casting, and platform independence. It also discusses keywords, core concepts, arrays, packages, inheritance, exception handling, threads, interfaces, applets, file handling, streams, strings, vectors, and various programming tasks. Each section includes definitions, explanations, examples, and programming exercises to illustrate the concepts.

Uploaded by

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

I.

Fundamentals of Java:

1. a) Enlist r features of Java. b) Describe any four features of Java.


2. State the significance of Java Virtual Machine (JVM) in the Java
programming environment.
3. a) Define the terms with examples: i) Class ii) Object b) Define
constructor. List its types. Explain parameterized constructor with a
suitable example. c) What happens if you don't define any constructor
in a class? Can you still create objects of that class? Explain with an
example.
4. a) Enlist any two logical operators and two bitwise operators. b)
Explain any two logical operators in Java with an example. c) Write a
program to demonstrate the use of the conditional operator and switch
case statement.
5. a) Enlist any two access specifiers with syntax. b) Enlist and explain
four access specifiers in Java.
6. Describe type casting in Java with an example. Explain implicit and
explicit type conversion with examples in detail.
7. Differentiate between String and StringBuffer class (any four points).
8. Explain the concept of platform independence in Java and discuss how
it is achieved. Give an example to illustrate the concept.

II. Keywords and Core Concepts:

9. Write the use of the 'this' keyword. Explain the usage of the 'this'
keyword in Java and give an example to illustrate its usage and
benefits.
10. Write the use of the 'super' keyword. How can the "super"
keyword be used in inheritance? Give an example to demonstrate its
usage.
11. Write the use of the 'Final' keyword with a suitable example.
12. Explain dynamic method dispatch mechanism with a suitable
example.
13. Explain the concept of argument passing in Java and give an
example to illustrate its usage and benefits.

III. Arrays:

14. a) Define array. List its types. b) Write down the syntax of array
declaration and initialization.
15. a) Write a program to sort the elements of an array in ascending
order. b) Write a program to copy all elements of one array into
another array.
IV. Packages:

16. a) Give a syntax to create a package and accessing package in


Java. b) List out different ways to access a package from another
package. c) Explain how to create a package and import it with a
suitable example. d) Describe the package in Java with a suitable
example. e) 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.

V. Inheritance:

17. Explain multilevel inheritance with an example.


18. a) Implement the following inheritance. (Refer to Fig. No. 01 from
the original document). b) Write a program to show Hierarchical
inheritance. c) Write a program to implement the following inheritance.
(Refer to Fig. No. 1 from the original document).

VI. Exception Handling:

19. a) Explain the use of throw and throws. b) Write a program to


create a user-defined exception in Java. c) Write a program to create a
user-defined exception "MIN-BAL". Throw the exception when the
balance in the account is below 500 rupees. d) Define an exception
called 'No Match Exception' that is thrown when the password
accepted is not equal to 'MSBTE'. Write the program. e) Write a
program that throws an exception called "NoMatchException" when a
string is not equal to "India". f) 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. g) i) Explain Errors and its types in detail.

VII. Threads:

20. a) Define thread. Mention 2 ways to create a thread. b) Explain


two ways of creating threads in Java with a suitable example.
21. a) State the use of the finalize() method with its syntax. b) Give
the use of garbage collection in Java. c) Explain garbage collection
mechanism in Java with a suitable example.
22. a) Differentiate between starting a thread with the run() method
and the start() method. b) Define Thread. Draw the life cycle of
Thread. c) Draw and explain the life cycle of a thread. d) Explain thread
life cycle with a neat diagram.
23. a) Give a syntax of the following thread methods: i) notify() ii)
sleep() 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) 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. d) Write a program to print even and odd numbers
using two threads with a delay of 1000ms after each number. e) ii)
Explain thread methods to set and get priority.

VIII. Interfaces:

24. a) Define the interface in Java. Write the syntax. b) Describe the
interface in Java with a suitable example. c) Develop an Interest
Interface which contains Simple Interest and Compound Interest
methods and a static final field of rate 25%. Write a class to implement
those methods.

IX. Applets:

25. a) Enlist the life cycle methods of Applet. b) Explain the applet
life cycle in detail. c) Explain the applet life cycle with a neat diagram.
d) Explain the life cycle of an Applet with a suitable example.
26. a) Write the use of the <PARAM> tag in an applet. b) Give the use of
the <PARAM> tag in the applet. c) Give a syntax of the <PARAM> tag to pass
parameters to an applet. d) Design an Applet using <PARAM> tag to
accept two numbers and perform arithmetic operations.
27. a) State the classes that an applet can extend. b) Write an applet
program for the following graphics methods: i) drawOval() ii) drawLine()
c) Write a program to design an Applet showing three concentric circles
filled with three different colors. d) Write a program to draw a
chessboard in Java Applet.
28. a) Write syntax of drawRect(). b) Explain the following with
syntax: i) drawLine() ii) drawOval() iii) drawArc() iv) drawString() c)
Explain any four font methods with an example. d) Write a program to
generate the following output using the drawLine() method. (Refer to
Fig. No. 2 from the original document).
29. Give the usage of the following: i) setColor() ii) getColor() iii)
setForeground() iv) setBackground()

X. File Handling and Streams:

30. a) Give two methods of the File class. b) Write a program to


create a new test file named "data.txt" using the File class. Write a
program to count the number of words in "data.txt" using stream
classes.
31. a) Write syntax to open a file using the InputStream class. b)
Define stream class and list types of stream class. c) What is the
concept of streams in Java? How do streams facilitate input and output
operations? d) Differentiate between Byte Stream Class and Character
Stream Class (any four points). e) Enlist types of Byte stream class and
describe the input stream class and output stream class.
32. a) Write a Java program to copy the contents of one file into
another. b) Write a program to read a file and then count the number
of words. c) Write a program for reading and writing characters to and
from the given files using character stream classes. d) Write a program
to append the content of one file into another file. e) Enlist any four
methods of the FileInputStream class and give the syntax of any two
methods.

XI. String and Vector:

33. a) Explain vector with the help of an example. Explain any 3


methods of the vector class. b) Write a program to show the use of a
copy constructor. c) Explain any four methods of the vector class with
an example. d) Describe the use of any six methods of the vector class
with their syntax.

XII. Programs:

34. Write a program using sqrt() and pow() to calculate the square
root and power of a given number.
35. Write a program to accept four numbers from the user using
command-line arguments and print the smallest number.
36. Write a program to display the ASCII value of the number 9.
37. a) Define a class employee having data members as emp_id, name,
and salary. Accept and display the data for five employees. b) Define a
class employee with data members empid, name, and salary. Accept data
for three objects and display it. c) Write a program to define class
Employee with members as id and salary. Accept data for five
employees and display details of employees getting the highest salary.
38. Write a program which displays the functioning of an ATM
machine (Hint: Withdraw, Deposit, Check Balance, and Exit).
39. Write a program to print all the Armstrong numbers from 0 to
999.
40. Write a program to check whether the entered number is an
Armstrong number or not.
41. 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 the user.
42. Write a program to show the use of a copy constructor.

XIII. Method Overloading and Overriding:


43. Differentiate between method overloading and method
overriding.

You might also like