stud
bud
Sign up
Log in
Home
Library
Explore
SAT
More
ooooooop Flashcards | StudBud
Explore
/
ooooooop
ooooooop
38 terms
·
StudBud Administration
·
2 plays
Imported from external platform
Flashcards
38 cards
F
Practice quiz
P
Host live
L
Questions
38
Answers
1
What does the finally block do?
Skips if no exception
Executes always
Only executes on IOException
Only executes if exception occurs
2
What is required for method overriding?
Static method only
Method with different return types
Different method name
Method with same signature in subclass
3
What does method overriding allow in Java?
Compile-time polymorphism
Object hiding
Runtime polymorphism
Static behavior
4
Which of the following best describes polymorphism?
Treating objects as instances of their parent class
Compiling multiple programs
Method hiding
Running multiple as instances of their parent class
5
Which of the following is true about method overloading?
It must have different method names
It uses the same method name with different parameters
It involves a subclass
It requires @Override annotation
6
Which class is used to write character data to a file?
FileInputStream
Scanner
FileWriter
BufferedReader
7
What is composition in Java?
A class implementing an interface
A class containing objects of another class
A class extending another class
A class using final methods
8
Which is an example of runtime polymorphism?
Method overloading
Field hiding
Class instantiation
Method overriding
9
What is required for method overriding?
Static method only
Different method name
Method with same signature in subclass
Method with different return types
10
What does reusability mean in OOP?
Using interfaces
Using same variable names
Writing same code again
Reusing code via inheritance
11
What will be the output of the following code?
Compilation error
Animal makes a sound
Dog barks
Runtime error
12
Which of the following keywords is used to define an abstract class?
static
abstract
interface
final
13
Which of the following represents inheritance?
Object has fields
Object overrides toString method
Object contains other objects
Object inherits methods from a parent
14
Which is an example of runtime polymorphism?
Field hiding
Method overriding
Class instantiation
Method overloading
15
What is compile-time polymorphism?
Interface usage
Method overloading
Method overriding
Abstract class usage
16
What is true about interfaces in Java?
They can be instantiated
They can contain constructors
They can't be implemented
They define a contract with abstract methods
17
What is method overloading in Java?
Redefining a method in a subclass but different parameter lists
Static methods only but different parameter lists
Methods with the same name and body but same lists
Multiple methods with the same name but different parameter lists
18
Which API is used for connecting Java to databases?
Spring
JDBC
JPA
Hibernate
19
What is compile-time polymorphism?
Abstract class usage
Method overriding
Interface usage
Method overloading
20
What is the purpose of Scanner in File I/O?
To write to a file and strings from input
To delete files and strings from input
To rename files and strings from input
To read primitive values and strings from input
21
What does reusability mean in OOP?
Using interfaces
Reusing code via inheritance
Using same variable names
Writing same code again
22
Which method is used to establish a connection to a database?
run()
getConnection()
connect()
execute()
23
Which class reads text efficiently line by line?
FileInputStream
BufferedWriter
BufferedReader
DataInputStream
24
What does the finally block do?
Only executes if exception occurs
Only executes on IOException
Executes always
Skips if no exception
25
What is Apache POI used for?
Image processing
Microsoft Office document handling
Web development Web development
Database queries
26
What is composition in Java?
A class implementing an interface
A class using final methods
A class containing objects of another class
A class implementing an interface
27
What is the function of ResultSet in JDBC?
To format the data
To read results from a query
To close the connection
To execute SQL commands
28
What does the Spring framework provide?
Dependency Injection and MVC
Manual memory management
Database tuning
Java applets
29
Which of the following is true about abstract classes?
They can have both abstract and concrete methods
They must be interfaces
They contain only abstract methods
They can be instantiated
30
Which of the following is true about method overloading?
It uses the same method name with different parameters
It must have different method names
It involves a subclass
It requires @Override annotation
31
What is the purpose of Scanner in File I/O?
To read primitive values and strings from input
To delete files
To rename files
To write to a file
32
What is the purpose of the try block?
To finalize resources
To execute code that may throw an exception
To catch exceptions and ignore errors
To ignore errors and execute the code
33
How do you define a custom exception class?
class MyEx throws Exception
class MyEx implements Exception
class MyEx extends Exception
class MyEx extends Throwable
34
What is the function of ResultSet in JDBC?
To format the data
To read results from a query
To close the connection
To execute SQL commands
35
What is required for method overriding?
Method with same signature in subclass
Method with different return types
Different method name
Static method only
36
Which Java specification provides ORM in Java EE?
Spring
JDBC
Servlet
JPA
37
What is the function of ResultSet in JDBC?
To execute SQL commands
To close the connection
To format the data
To read results from a query
38
What is the main purpose of Hibernate?
Object-relational mapping
Managing threads
Building UI
Handling HTTP requests