CS222 Final Exam
Which of the following is NOT a valid Java identifier?
2ndName
In JUnit, which annotation is used to indicate a test method?
@Test
In Java, a class is:
A blueprint from which individual objects are created.
High cohesion in object-oriented design typically means:
A class has focused, single responsibility
Inheritance in Java allows:
A class to inherit methods and attributes from another class
In the context of version control with Git, what is a 'branch'?
A copy of the main code, typically used to develop a feature.
What is recursion in Java?
A process in which a method calls itself continuously.
Encapsulation in Java is:
A process of wrapping code and data together into a single unit.
Which of the following best describes an object in Java?
A runtime entity
A procedure in programming is:
A set of instructions that performs a task
Which of the following best describes an Abstract Data Type (ADT)?
A set of operations independent of their implementation
Overriding in Java refers to:
A subclass providing a specific implementation of a method in a superclass
Version control systems are important in team projects because they:
Allow tracking of changes and collaboration
Polymorphism in Java:
Allows objects to be defined in multiple forms
What is the "Diamond Problem" in Java?
An issue related to multiple inheritance of classes.
Which of the following is NOT a tool used for program development?
Binary Search Trees
A 'static' method in Java means that the method:
Can be called without creating an instance of the class
In Java, a try-catch block is used to:
Catch and handle exceptions
In Java, an interface can:
Contain default and static methods along with abstract methods.
Evaluating algorithms for errors is important to ensure:
Correctness
the 'finally' block in Java is used to:
Execute code regardless of whether an exception is thrown
A custom exception in Java is created by:
Extending the Exception class or one of its subclasses
Which class is used to read data from a file in Java?
FileReader
Which type of repetition structure is most suitable for iterating over a known range of values?
For loop
Encapsulating exceptions in Java is done to:
Group and manage different types of exceptions
The primary purpose of code reviews in a team using Git is to:
Identify and fix bugs, improve code quality, and share knowledge.
Method overriding in Java is:
Implementation of a method in a subclass that exists in the superclass.
Which of these is NOT a benefit of exception handling in Java?
Increased performance.
What is the main advantage of using recursion in programming?
It can simplify the code for complex problems
Why is unit testing important in Java development?
It helps in detecting early defects in code.
Which framework is commonly used for Unit Testing in Java?
JUnit
Which of the following is true about file handling in Java?
Java uses classes like FileReader and FileWriter for file handling
Recursion in programming is often used instead of:
Loops
Which of the following is true about inheritance in Java?
Mechanism where one class can inherit the features of another class
Which of the following is NOT a member of a class in Java?
Packages
In the context of Java programming, 'DevOps' primarily refers to:
Practices that automate processes between software development and IT teams
Which access specifier allows visibility only within the same package and subclasses?
Protected
The 'super' keyword in Java is used to:
Refer to the superclass version of a method or variable.
In Java, a try block is used to:
Test a block of code for errors.
Polymorphism in Java refers to:
The ability of a variable, function, or object to take on multiple forms.
Which of the following is a recent advance in Java programming?
The introduction of AI-based coding assistants.
In Java, which of the following is true about arrays?
They are zero-indexed
Which of the following is true about interfaces in Java?
They can contain only abstract methods
Which of the following is true about abstract classes in Java?
They can have both abstract and concrete methods
What is the primary purpose of Unit Testing in Java?
To test individual components or functions for correctness
In Java, which keyword is used to inherit a class?
extends
In Java, which keyword is used to declare a constant?
final
The difference between print() and println() in Java is that:
print() prints text w/o a newline, while println() prints text with newline