stud
bud
Sign up
Log in
Home
Library
Explore
SAT
More
Programming Fundamentals 2 Flashcards | StudBud
Explore
/
Programming Fundamentals 2
Programming Fundamentals 2
10 terms
·
StudBud Administration
·
21 plays
Imported from external platform
Flashcards
10 cards
F
Practice quiz
P
Host live
L
Questions
10
Answers
1
What will the following code output?
1, 2, 3
No output
An exception occurred: Index out of bounds
Index out of bounds!
2
What does method overloading allow in Java?
Multiple methods with different names
Multiple methods with the same name and same parameters
Multiple methods with the same name but different parameter lists
Multiple methods with the same name but different return types
3
Which of the following is an example of a checked exception?
ArithmeticException
IOException
NullPointerException
ArrayIndexOutOfBoundsException
4
What keyword is used to declare an exception that might be thrown in a method?
throws
catch
try
throw
5
What is the purpose of a constructor in a class?
To instantiate new objects
To perform mathematical operations
To display information about the object
To define variables
6
In exception handling, what does the try block do?
It contains code that might throw an exception.
It handles the exception.
It declares the exception.
It terminates the program.
7
Which of the following correctly represents the syntax of a class in Java?
public class ClassName {}
public ClassName {}
class ClassName {}
ClassName class {}
8
Which type of exception indicates a programming error and is not checked at compile time?
Unchecked Exception
Custom Exception
Checked Exception
Runtime Exception
9
What is an example of a no-parameter method?
public void showWelcomeMessage() { System.out.println("Welcome!"); }
public double multiply(double a, double b) { return a * b; }
public int add(int a, int b) {}
public String getName(String name) { return name; }
10
What is the primary purpose of methods in Java?
To create objects
To perform specific tasks
To store data
To define classes