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

Java Exam 2025 Questions and Answers

Rating
-
Sold
-
Pages
56
Grade
A+
Uploaded on
08-05-2025
Written in
2024/2025

Java Exam 2025 Questions and Answers

Institution
JAVA
Course
JAVA











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

Written for

Institution
JAVA
Course
JAVA

Document information

Uploaded on
May 8, 2025
Number of pages
56
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

Java Exam 2025 Questions and
Answers


If you overwrite clone(), which 3 rules must this method obey? - ANSWER✔✔-1) the

new object should be new: memory address should differ


2) Both should be an object of the same class


3) Both should be in the same state:


a.clone().equals(a) == true


Why do we need to implement the Clonable interface? - ANSWER✔✔-At runtime it

would throw the CloneNotSupportedException if we don't implement the Cloneable

interface. A class implements the Cloneable interface to indicate to the Object.clone()

method that it is legal for that method to make a field-for-field copy of instances of that

class.


What is a marker interface? - ANSWER✔✔-A Marker interface, has no method.


Serializable, Clonable are marker interfaces.

,How do you clone an object? - ANSWER✔✔-MyClone a = (MyClone) c.clone()


- TypeCast is nessesary.


- handle CloneNotSupportedException


Why can Annotations replace marker interfaces? - ANSWER✔✔-Annotations can

convey metadata about the class to its consumers without creating a separate type for it.

Annotations let you pass information to classes that "consume" it.


What is Double-Checked Locking? - ANSWER✔✔-To reduce the overhead of acquiring

a lock by first testing the locking criterion without actually acquiring the lock.


How do you make an object serializable? - ANSWER✔✔-The class must implement the

java.io.Serializable interface


Java object serialization is performed using which classes? - ANSWER✔✔-Java object

serialization (writing) is done with the ObjectOutputStream and deserialization

(reading) is done with the ObjectInputStream.


What is serialVersionUID? - ANSWER✔✔-In addition to implementing the Serializable

interface, a class intended for serialization should also contain a private static final long

variable named serialVersionUID.

,The serialVersionUID variable is used by Java's object serialization API to determine if a

deserialized object was serialized (written) with the same version of the class, as it is

now attempting to deserialize it into.


If you make changes to the class that affect serialization, you should also change its

serialVersionUID value.


What is escape analysis? - ANSWER✔✔-escape analysis is a method for determining

the dynamic scope of pointers - where in the program a pointer can be accessed.


What is the size of byte? - ANSWER✔✔-8 bits


What is the size of char? - ANSWER✔✔-16 bits


What is the size of short? - ANSWER✔✔-16 bits


What is the size of int? - ANSWER✔✔-32 bits


what is the size of long? - ANSWER✔✔-64 bits


what is the size of float? - ANSWER✔✔-32 bits


what is the size of double? - ANSWER✔✔-64 bits


What is the range of byte - ANSWER✔✔--128 to 127


What is the range of short? - ANSWER✔✔--32,768 to 32,767


What is the range of int? - ANSWER✔✔--2,1 billion to 2,1billion

, How do you check if a number is even? - ANSWER✔✔-check if number AND 1 is 0


How do you test if the n-th bit is set? - ANSWER✔✔-Shift n times to the right and then

AND


How can you set the n-th bit - ANSWER✔✔-Shift n times to the left and OR


How can you unset the nth bit - ANSWER✔✔-Shift n times to the left and invert, then

AND


How can you toggle the nth Bit? - ANSWER✔✔-Shift n times to the left and XOR


How can you turn off the rightmost 1Bit? - ANSWER✔✔-AND with (number - 1)


How can you return only 1 or 0 for the rightmost 1Bit value? - ANSWER✔✔-number &

( - number)


How can you also declare -x bitwise? - ANSWER✔✔-~x + 1


What is ~0 bitwise? - ANSWER✔✔-0


How can you right propagate the rightmost 1-bit? - ANSWER✔✔-number OR (number

- 1), does not work for 0


What is -1 in twos complement? - ANSWER✔✔-1111 1111


How can you isolate the rightmost 0-bit? - ANSWER✔✔-invert number AND (number

+ 1)

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
KatelynWhitman West Virginia University
View profile
Follow You need to be logged in order to follow users or courses
Sold
1084
Member since
2 year
Number of followers
482
Documents
33022
Last sold
5 hours ago
Golden Quill Emporium Store

Get Yourself Well-Researched Study Materials to Ace Your Online& Actual Exam Tests with Confidence. STUDY LIKE A PRO WITH A WELL FORMATTED Q&A MATERIALS.

3.6

235 reviews

5
94
4
38
3
54
2
20
1
29

Recently viewed by you

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