Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
13 views19 pages

Mid 1

Uploaded by

yaaryaari6253243
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)
13 views19 pages

Mid 1

Uploaded by

yaaryaari6253243
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/ 19

SRI INDU COLLEGE OF ENGG & TECH (Regulation :R22)

QUESTION BANK Prepared on


(Regulation :R22) :15/02/2024
DEPARTMENT OF COMPUTER SCIENCE &
INFORMATION TECHNOLOGY Rev1: 15/02/2024
Page: 1 of 7
Sub.Code & Title (R22CSI2215) JAVA PROGRAMMING
Academic Year: 2023-2024 Year/Sem: II YEAR II/I SEM: II SEM
Faculty Name & Designation SHEK SHAKEEL, ASSISTANT PROFESSOR

QUESTION BANK WITH BLOOMS TAXONOMY LEVEL


(BTL)
(1.Remembering 2.Understanding 3. Applying 4.Analyzing
5.Evaluating 6.Creating)

UNIT-I: Foundations of java AND OOP Principles

Multiple Choice Questions Course


BT Outcome
Level
1C-1 Which of the following is not an OOPS concept in Java? [ ]
I CO1
a) Polymorphism
b) Inheritance
c) Compilation
d) Encapsulation
1C-2 Which environment variable is used to set the java path? [ ]
II CO1
a) MAVEN Path
b) Java PATH
c) JAVA
d) JAVA_HOME

1C-3 ________ is used to find and fix bugs in the Java programs.
II

a)JVM
b)JRE
c)JDK
d)JDB
1C-4 …… is not the use of “this” keyword in Java? [ ]
I CO1
a) Referring to the instance variable when a local variable has the same name
b) Passing itself to the method of the same class
c) Passing itself to another method
d) Calling another constructor in constructor chaining

What is the extension of compiled java classes? [ ]


I CO1
1C-5 a) .txt
b) .js
c) .class
d) .java
1C-6 Which of the following is a Super class of every class in Java? [ ]
I CO1
a) Array List
b) Abstract class
c) Object class
d) String

1C-7 Which one of the following is not an access modifier? [ ]


IV CO1
a) Protected
b) Void
c) Public
d) Private
1C-8 What is the numerical range of a char data type in Java? [ ]
I CO1
a) 0 to 256
b) -128 to 127
c) 0 to 65535
d) 0 to 32767
1C-9 What is the return type of Constructors? [ ]
III CO1
a) int
b) float
c) void
d) none of the mentioned
1C- Which of the following is a method having same name as that of its class? [ ]
I CO1
10 a) finalize
b) delete
c) class
d) constructor

Fill in the blanks

1F-1 In OOP, objects are instances of __________, which are templates for creating objects.
I CO1
1F-2 The four pillars of OOP are __________, __________, __________, and __________. III CO1
1F-3 __________ is the ability of a class to have multiple methods with the same name but III CO1
different parameters.

1F-4 URL stands for -------------------. I CO1

1F-5 The __________ keyword is used to create an object of a class. CO1


III

1F-6 ----------------- is the java compiler. I CO1

1F-7 __________ is the process of creating new classes based on existing classes, allowing
for code reuse and extension. I CO1
1F-8 The ability to take more than one forms is called ---------------- CO1
III

1F-9 Every object has a _____________ and ____________. CO1


I

1F-10 Constructor overloading is a mechanism, where ___________________________. III CO1

Match the following


1M-1 Match the following.
I CO1
a) Java 1) is a tool for debugging java program
b) Javah 2) is a tool for creating C-like header files
c) Javap 3) runs java byte code
d) jdbc 4) prints java code representation
1M - Match the following.
2 II CO1
a) Array 1) Acquiring properties from base class
b) Inheritance 2) More than one form
c) Polymorphism 3) Non-primitive data type
d) Encapsulation 4) Wrapping up of data
1M - Match the following.
3 II CO1
a) Public 1) Accessing the data members inside the class
b) Private 2) within the same package or subclasses in different
packages.
c) Default 3) Accessing the data members & member functions outside
the class
d) Protected 4) when we don't use any keyword explicitly.
1M - Match the following.
4 II CO1
a) 1Megabyte 1) 1024 gigabyte
b) 1Gigabyte 2) 1024 kilobyte
c) 1Terabyte 3) 1024 terabyte
d) 1Petabyte 4) 1024 megabyte
1M - Match the following.
5 III CO1
a) Class 1) Instance of an class
b) Object 2) Combination of Objects.
c) Abstract class 3) Java Virtual Machine
d) JVM 4) Abstract keyword
5 - MARKS QUESTIONS
1D-1. Explain about Features of Java.
I CO1
1D-2. Explain about OOPs concepts along with examples.
III CO1

1D-3. Explain about Relational and Assignment Operators in java.


II CO1

ID-4. Discuss in detail about Control statements.


II
1D-5. What is Encapsulation , Discuss how it works with the help of Getter and Setter III CO1
methods.
1D-6. Write short notes on “new”, “this” ,“super” ,”static”, ”final” keywords in Java? II CO1
1D-7 Explain about Constructors in Java and types of constructors with an example IV CO1
program.
1D-8 Define Polymorphism and explain about Method overloading and Method III CO1
Overriding
1D-9 Define Array and types of arrays in Java? I CO1
1D-10 Define inheritance, Develop a java program on multilevel inheritance. VI CO1

UNIT-II: Exception Handling & Files and I/O Streams


Multiple Choice Questions Course
BT Outcome
Leve
l
2C-1 What is the main purpose of exception handling in Java? [ ]
III CO2
a. To encourage unchecked exceptions
b. To avoid writing any error-handling code
c. To handle runtime errors gracefully
d. To crash the program when an error occurs
2C-2 Which of the following is not a part of exception handling in Java? [ ]
a. try II CO2
b. catch
c. throw
d. static

2C-3 In the context of exception handling, what is a "checked exception"? [ ]


a. An exception that is checked at compile-time II CO2
b. An exception that is checked at runtime
c. An exception that is never checked
d. An exception that doesn't need to be caught
2C-4 Which keyword is used to explicitly throw an exception in Java? [ ]
III CO2
a. throws
b. throw
c. try
d. catch

Which block in Java's exception handling is used to execute code regardless of whether
I CO2
2C-5 an exception occurs or not? [
]
a. try
b. catch
c. finally
d. throw

2C-6 What is the top-level class in the Java exception hierarchy? [ ]


II CO2
a. Error
b. Exception
c. Throwable
d. Runtime Exception
2C-7 Which of these methods are used to read in from file?
III CO2
a. get()
b. read()
c. scan()
d.readFileInput()
2C-8 Which of these methods is used to write() into a file?
II CO2
a. put()
b. putFile()
c. write()
d. writeFile()
2C-9 Which of these class contains the methods used to write in a file?
I CO2
a. FileStream
b. FileInputStream
c. BUfferedOutputStream
d. FileBufferStream
2C- Which of these exception is thrown in cases when the file specified for writing is not
10 found?
a. IOException
b. FileException
c. FileNotFoundException
d. FileInputException

Fill in the blanks

2F-1 Exception handling is a mechanism used to handle ___ errors or exceptional situations
I CO2
in Java.
2F-2 The primary benefit of exception handling is to handle ________________. I CO2
2F-3 The keyword used to explicitly throw an exception in Java is __________________. IV CO2

2F-4 The block in Java's exception handling that is used to execute code regardless of whether I CO2
an exception occurs or not is the _______________________ block.
2F-5 The top-level class in the Java exception hierarchy is __________________. CO2
I,II
2F-6 Exception is _____________________________. I CO2

2F-7 Try must be followed by either_______________ or _____________.


I CO2
2F-8 Catch must be preceded by ________________. CO2
III

2F-9 The file class is known as ______________________________________________’ CO2


I

2F-10 Stream is a ____________________________. II CO2

Match the following


2M-1 Match the following
1) Class a) Checked and unchecked exceptions II CO2
2) Exceptions b) Compile time exceptions
3) Errors c) Exceptions and errors
4) Object d) JVM crashes and Assertion errors
2M - Match the following
2 1) try block a) Must be executed III CO2
2)catch block b) It contains exception thrown out of method
3)finally block c) throw an exception try to catch
4)throw block d) Can raise exceptions
2M - Match the following
3 1) Start ( ) a) wait for a thread to terminate II CO2
2) Sleep( ) b) start thread by calling its run method
3) run( ) c) Determine if a thread is still running
4) join( ) d) Suspend a thread for a period of time
2M - Match the following
4 IV CO2
1) Class a) Collection of Objects
2) Object d) Must be executed
3)finally block c) Instance of a Class
4) Exception d) throws an exception
2M - Match the following
5 I CO2
1) charAt ( ) a) to extract more than one character at a time from a
string.
2) getchars( ) b) to extract a single character from a string.
3) getBytes( ) c) it returns an array of characters for the entire string.
4) toCharArray( ) d) to store the characters in an array of bytes.
5 - MARKS QUESTIONS
2D-1. Explain the concept of Exception handling in Java. What are the main benefits of
II CO2
using exception handling in Java programming?
2D-2. Explain the purpose of the try, catch, and finally blocks in Java's exception handling.
VI CO2
Provide a code example to illustrate their usage.
2D-3. Discuss the Java exception hierarchy. What is the significance of
IV CO2
the Throwable class, and how does it relate to Error and Exception?
2D-4. How can you create your own custom exception subclass in Java? Provide an example VI CO2
of when and why you might create a custom exception.
2D-5. Explain the purpose of the try and catch, Provide a code example to illustrate their III CO2
usage.
2D-6. Explain in detail about Random access file. I CO2
2D-7. Explain about stream and Discuss different operations on streams. I CO2
2D-8 Discuss in detail about filtered byte Streams. II CO2
2D-9 Define file class and explain in detail about fields and methods of file. V CO2
2D-10 Define Byte stream class and explain about input and output stream classes. II CO2
UNIT-III: Packages&Collections
Multiple Choice Questions Course
BT Outcome
Level
3C-1 A class member declared protected becomes a member of subclass of which type? I CO3
[ ]
a) public member
b) private member
c) protected member
d) static member
3C-2 Which of these keywords is used to define packages in Java? [ ] I CO3
a) pkg
b) Pkg
c) package
d) Package

3C-3 Which of the following package stores all the standard java classes? [ ] III CO3
a) lang
b) java
c) util
d) java.packages
3C-4 …….of these can be used to fully abstract a class from its implementation? I CO3
a) Objects [ ]
b) Packages
c) Interfaces
d) None of the Mentioned
3C-5 Which of these packages contains abstract keyword? [ ] IV CO3
a) java.lang
b) java.util
c) java.io
d) java.system
3C-6 Which system property stores installation directory of JRE? [ ]
I CO3
a) user.home
b) java.class.path
c) java.home
d) user.dir
3C-7 What is Collection in Java?
I CO3
a) A group of objects
b) A group of classes
c) A group of interfaces
d) None of the mentione
3C-8 Which of these methods deletes all the elements from invoking collection?
II CO4
a) clear()
b) reset()
c) delete()
d) refresh()
3C-9 Which of this interface is not a part of Java’s collection framework?
II CO4
a) List
b) Set
c) SortedMap
d) SortedList
3C- Which of these classes is not part of Java’s collection framework?
I CO4
10 a) Maps
b) Array
c) Stack
d) Queue

Fill in the blanks


3F-1 A _______________ variable is a variable that is shared by all objects of a class.
II CO3
3F-2 While creating a package, you should choose a name for the package and include II CO3
a ____________statement

3F-3 A class ___ an interface, while a class ___ an abstract class. I CO3

3F-4 An Interface cannot contain a__________ methods. II CO3

3F-5 CLASSPATH is an environment variable which is used by Application Class Loader to CO3
II
locate and load the .class files.

3F-6 Collection is a __________________________________’ I CO3


3F-7 An interface is a ________________________________.
II CO3
3F-8 Package is collection of ____________________ and ________________. CO4
II
3F-9 Sub package is known as _________________. CO4
III
3F-10 ______________ method deletes all the elements from invoking collection IV CO4

Match the following


3M-1 Match the following
1) Inheritance a) Used to specify the behavior of class II CO3
2) Interface b) Importing classes or interfaces
3)Package c) importing entire package
4) Import pkg.* d) Default package
3M - Match the following
2 1) java.applet a) provides for system input & output III CO3
2)java.awt b) creating and modifying image
3)java.awt.image c) Contains collection frameworks
4) java.io d) Provides graphical user interface
3M - Match the following
3 1)CLASSPATH a) provides for system input & output II CO4
2)public static final b) creating and modifying image
3)public abstract c) An environment variable
4) Multilevel inheritance d) more than one base classes
3M - Match the following
4 VI CO4
1) Default method a) extension method
2) Static method b) it can’t be overridden by sub class
3) Final method c) a method that belongs to a class method.
4) Super keyword d) current object in a method

3M - Match the following


5 III CO4
1) Single inheritance a) not supportable in java
2) Multiple inheritance b) one base class , one derived class
3) Hierarchical inheritance c) one base class, intermediate class, derived class
4) Multilevel inheritance d) single inheritance, hierarchical inheritance
5 - MARKS QUESTIONS
3D-1.
1. Define Package and explain how to access package from another package.
II CO3
3D-2. Explain about CLASSPATH, and how to set CLASSPATH.
II CO3
3D-3.
2. Discuss in details about access specifiers.
II CO3
3D-4.
3. Explain about utility classes and what are advantages of utility classes. CO3

3D-5.
4. Explain about String Tokenizers, methods if string tokenizers in detail. II CO3

3D-6.
5. Write a program to illustrate access specifiers. VI CO4

3D-7.
6. What is collection, and explain collection framework in detail. IV CO4

3D-8
7. Discuss briefly about methods involved in Collection interface. II CO4
3D-9
8. Define and explain about Sorting in Collections. III CO4

3D-10
9. Differentiate Comparable and Comparator interface. II CO4

UNIT-IV: Multithreading &Java Database Connectivity


Multiple Choice Questions Course
BT Outcome
Level
4C-1 What is an thread in Java? [ ] II CO5
a) A light process that runs independently within a prpgram
b) A type of loop
c) An data structure to store variables
d) A synchronization mechanism
4C-2 Which interface is used to create a thread in java? [ ] I CO5
a)Processor
b)Executor
c)Threadable
d)Runnable
4C-3 What is the main advantage of using multithreading in Java programs? [ ] III CO5
a)Reduced memory usage
b)Simplicity of code
c)Improved program performance by utilizing multiple CPU’s or CPU cores
d)Elimination of exceptions
4C-4 What is the purpose of the start() method in Java thread? [ ] I CO5
a)It resumes the execution of a thread
b)It suspends the execution of a thread
c)It starts the execution of a new thread
d)It stops the execution of a thread
In Java event handling, what is the delegation event model? [ ]
I CO5
4C-5 a) It's a model that delegates event handling to the operating system.
b) It's a model where event sources delegate event handling to registered listeners.
c) It's a model that delegates event handling to the user interface thread.
d) It's a model used for database event handling.
4C-6 In Java, a thread be restarted after it has completed execution? [ ] IV CO5
a) Yes,a thread can be restarted multiple times
b) Only if the thread is marked as “final”
c) Only if the thread is marked as “static”
d) No, a thread cannot be restarted once it has completed
4C-7 How can you achieve synchronization between threads in Java? [ ] I CO5
a) By using the interrupt() method
b) By using the wait() and notify()method
c) By using multiple catch blocks
d) By using the synchronized keyword or synchronized blocks
4C-8 What is a race condition in multithreaded Java programs [ ] V CO5
a)A situation where threads synchronize perfectly
b)A situation where threads never finish executing
c)A situation where multiple threads access shared data simultaneously.leading to
unpredictable results
d)A situation where threads throw exceptions

4C-9 In Java, what is the purpose of the interrupt() method in threads? I CO5
a)It resumes the thread
b)It pauses the thread
c)It interrupts the normal execution of a thread, causing it to throw an
InterruptedException
d)It stops the thread permanently
4C-10 Which keyword is used to declare a synchronized method in Java? [ ] VI CO5
a) sync
b) lock
c) thread-safe
d) synchronized
Fill in the blanks
4F-1 There are ________ threads in Java. II CO5
4F-2 Thread priority in java is __________. I CO5
4F-3 __________class is used to create a thread in java. I CO5

4F-4 _____________ method is used to start the execution of a thread. III CO5

4F-5 ____________number of threads that can be created in java program. CO5


I,II

4F-6 The ___________interface is used to define tasks that can be executed asynchrously. I CO5

4F-7 In java,the ______ keyword is used to define a synchronized block of code.


I CO5
4F-8 In java, a thread is represented by an instance of the ___________ class. CO5
IV
4F-9 The ______ method is used to wait fpr a thread to complete the execution. CO5
I
4F-10 Multithreading allows ______ to create concurrently ,improving overall performance. I CO5

Match the following

4M-1 Match the following


1) Button a) Generates item events I CO5
2)Check box b) Generates action events by clicking
3)Text components c) When an item is double clicked
4)List d) when the item selected or deselected
5)Menu item e) when user enters a character
4M -2 Match the following
1) Event a) Describes a state change II CO5
2)Listener b) Is an object that generates an event
3)Source c) Notified when an event occurs
4)Event Object d) Is generated by a scroll bar
5)Adjustment Event e)Is super class of all events
4M -3 Match the following
III CO5
1) Item Listeners a) Deactivated, activated, open or quit.
2) Event Listeners b) recognize when the state of an Item changes.
3) Delegation Event Model c) component gains or losses keyboard focus
4) Windows Listeners d) a source generates an Event and send it to
one or
more Listeners
5) Focus Listeners e) java. awt. event.
4M -4 Match the following
II CO5
1) Mouse Motion listener a) it gains or losses input focus
2) Mouse Wheel Listener b) it is activated or deactivated.
3) Text Listener c) mouse dragged, mouse moved
4) Window Focus Listener d) mouse wheel is moved
5) Window Listener e) change occurs in a text area.
4M -5 Match the following
IV CO5
1) Component Adapter a) mouse listener
2) Focus Adapter b) container listener
3) Key Adapter c) component Listener
4) Mouse Adapter d) key Listener
5) Container Adapter e) focus Listener
5 - MARKS QUESTIONS
4D-1. Define and discuss in detail about process in thread?
II CO5
4D-2. Differentiate thread based multitasking and process based mutli tasking?
II CO5
4D-3. Explain about java thread life cycle.
III CO5

4D-4. Discuss in detail about thread priority. II CO5

4D-5. Explain about types of driver. IV CO5

4D-6. Explain about JDBC . V CO5


4D-7. Discuss basic steps involved in developing JBC application. I CO5
4D-8 How to create a new database and table in java? II CO5
4D-9 Describe the Flow Layout, layout manager in AWT. How does it arrange II CO5
components within a container, and when is it most suitable for use?
4D-10 Explain the purpose of the Scroll Pane component in AWT. How does it help in I,II CO5
managing scrollable content within a GUI application, and provide an example of
its usage?
4D-11 Explain about Dialog Boxes in Event handling II CO5
4D-12 Write a java program on AWT buttons in Event handling I CO5
4D-13 Write a java program on Graphics in Event handling I CO5
4D-14 Write a java program on Combo box, Scroll bars, Lists in Item Listeners II CO5
4D-15 Write a java program on Menus and Menu bars in Event handling. II CO5
UNIT-V: GUI Programming With Swing&
Event Handling
Multiple Choice Questions Course
BT Outcome
Level
5C-1 Which of the following architecture does the swing framework use? [ I CO6
]
a) MVC
b) MVP
c) Layered architecture
d) Master-slave architecture

5C-2 Which language is used in the swing framework [ ] II CO6


a) JavaScript
b) Java
c) React
d) Python

5C-3 An ___________ is a change in the state of an item? [ I CO6


]
a) Spinner
b) Event
c) Occurrence
d) Activity
5C-4 In Java , how many types of events are there? [ ] III CO6
a) 5
b) 3
c) 2
d) 4

5C-5 What is the primary motivation behind the creation of Swing as GUI framework? IV CO6
[
]
a) To replace the AWT framework
b) To provide a platform-independent and modern GUI framework
c) To work only with native platform components
d) To simplify the server-side development
5C-6 Which keyword is used to handle exceptions in Java? [ ] I CO6
a) throws
b) throw
c) try
d) catch
5C-7 What is an exception in java? I CO6
a) An error that occurs during runtime
b) An error that occurs during compilation
c) A warning issued by the compiler
d) A type of loop
5C-8 What is the purpose of the “try” block in excerption handling? [ ] I CO6
a) It catches exceptions and handles them
b) It specifies the exception bugs
c) It contains the code that might throw an exception
d) It specifies the exception message

5C-9 In java, can method declare multiple exceptions using the “throws” keyword? [ IV CO6
]
a) Only if the method is marked as “static”.
b) Yes, a method can declare multiple exceptions separated by comas
c) Only if the exceptions are marked as “final”
d) Only if the method is marked as “dynamic”.
5C- What is the purpose of the “catch” block in exception handling? [ ] I CO6
10
a) It specifies the exception message
b) It specifies the exception type.
c) It catches exceptions and handles them
d) It contains the code that might throw an exception

Fill in the blanks

5F-1 In Java, exceptions are __________ events that occur during the execution of a program
II CO6
that disrupts the normal flow of instructions.

5F-2 The process of responding to exceptions and taking appropriate actions is known as I CO6
__________

5F-3 The base class for all exceptions in Java is __________. I CO6
5F-4 Checked exceptions must be either __________ or __________ in the method signature III CO6
or handled using a try-catch block.

5F-5 Unchecked exceptions, also known as __________, do not need to be declared or CO6
I,II
handled explicitly.

5F-6 A try block is used to __________ code that may throw exceptions. I CO6
5F-7 The catch block is used to __________ exceptions that are thrown within the
corresponding try block. I CO6
5F-8 The finally block is used to define __________ that will be executed regardless of CO6
II
whether an exception is thrown or not.

5F-9 The throw keyword is used to __________ a specific exception manually within a CO6
I
program.

5F-10 The throws keyword is used in a method signature to __________ that the method may IV CO6
throw certain types of exceptions.
Match the following

5M-1 ) Match the following


1) JComponent a) Light weight II CO6
2)JFrame b) Abstract Button super class
3)AWT c) Heavy weight
4)Swing d) AWT Frame class
5)JButton e) Container and one of the base classes of swing
5M - Match the following in AWT control fundamentals
2 I CO6
1) Labels a) methods are setText( ),getText( ).
2) Push buttons b) methods are setLabel( ),getLabel( )
3) Check boxes c) methods are setValue( ),getValue( )
4) Choice lists d) methods are setState( ),getState( )
5) Scroll bars e)methods are getSelectedItem( )or getSelectedIndex( )
5M - Match the following in AWT classes
3 III CO6
1) AWTEvent a) manages colors in a portable
2) AWTEventMulticaster b) a blank, symantics-free window
3) Canvas c) creates a pop-up list
4) Choice d) encapsulates AWT events
5) Color e)dispatches events to multiple Listeners

5M - Match the following in AWT classes


4 II CO6
1) Menu a) creates a menu item
2) Menubar b) encapsulates a keyboard shortcut for a menu item.
3) MenuComponent c) creates a pulldown menu
4) MenuItem d) creates a menu bar.
5) MenuShortcut e) an abstract class implemented by various menu
classes
5M - Match the following in Life cycle of an Applet
5 VI CO6
1) init ( ) a) it destroys the Applet program
2) Start( ) b) initialization of an Applet
3) Stop ( ) c) execution of an Applet code.
4) Destroy( ) d) it minimizes the Applet code
5) To run an Applet e) by HTML file, Applet viewer tool

W
5 - MARKS QUESTIONS
5D-1. What are the limitations of AWT.
V CO6
5D-2. Explain about MVC architecture? Components?
I CO6
5D-3. What are the Applications using AWT and Swing.
VI CO6
5D-4. What are the Event Listeners? What are the event classes. II CO6

5D-5. Design a simple application using GUI Swing. VI CO6

5D-6. Define AWT and application I CO6

5D-7. What are the handling mouse and keyword events. I CO6
5D-8 What are the Layout Manager Classes in GUI programming with swing. II CO6

5D-9 What are the Adapter class in GUI programming with swing. V CO6

5D-10 Explain the Delegation event model in Event Handling? I,II CO6

You might also like