100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

Java Programming Practice Test & Answer Key

Rating
-
Sold
-
Pages
5
Grade
A
Uploaded on
14-09-2024
Written in
2024/2025

Java Programming Practice Test & Answer Key

Institution
Junior / 11th Grade
Course
Math









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Junior / 11th grade
Course
Math
School year
4

Document information

Uploaded on
September 14, 2024
Number of pages
5
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Content preview

Java Programming Practice Test!!

There is also an answer key to check after finishing the practice test.

(Note: All the coding (Java) was done in a different software and posted into this
doc)

Section 1: Multiple Choice Questions

1. Which keyword is used to declare a constant in Java?
a) final
b) const
c) static
d) constant

2. What is the output of the following code snippet?

String str = "Java";
System.out.println(str.charAt(2));

a) J
b) a
c) v
d) Error

3. What is the access modifier used to specify that a method can only be accessed
within its own class and subclasses?
a) private
b) protected
c) public
d) default

4. Which of the following is a valid declaration of a two-dimensional array in Java?
a) int[][] arr = new int[3][3];
b) int arr[] = new int[3,3];
c) int arr[][] = new int(3)(3);
d) int arr[][] = new int[3,3];

5. What will the following code output?

, int x = 5;
int y = 2;
System.out.println(x / y);

a) 2
b) 2.5
c) 2.0
d) 2.5 (with a runtime error)

Section 2: True or False

6. In Java, a class can extend multiple classes.
- True
- False

7. The main method must be declared as public static void main(String[] args).
- True
- False

8. Java supports both call by value and call by reference for passing arguments to
methods.
- True
- False

9. A constructor can have a return type in Java.
- True
- False

10. The finalize() method is guaranteed to be called by the JVM before an object is
garbage collected.
- True
- False

Section 3: Short Answer Questions

11. Explain the difference between the == operator and the equals() method in Java.

12. What is the purpose of the keyword "this" in Java? Give an example.

13. Briefly describe the purpose of the "super" keyword in Java.
$7.99
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
tripletsteam

Get to know the seller

Seller avatar
tripletsteam
View profile
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
1 year
Number of followers
0
Documents
20
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions