•
•
•
017.
018.
a.
code?
Answer:
When a reference variable is not explicitly initialized, then its
value is
null by default. If such
variables are not properly
handled, they can result in a NullPointerException. So, in
order to avoid the NullPointerException, you can do one of
the following:
Ensure that variables
are properly initialized
Explicitly add null checks in your code
Use Java 8 Optionals
Explain the keywords “transient” and “native”.
Answer:
The
keyword transient can be used as a modifier for an instance
variable. It specifies that the JVM should ignore the variable while
serializing the containing object.
The keyword
native can be used as a modifier with methods. It
specifies that the method is implemented
in another language like
C, C++.
What is a comment in Java? Explain the types of
comments supported by Java.
Answer:
A comment is some text added to the code that provides
additional information about the code.
It describes what the code
does to the readers of the code. Comments are ignored by the
compiler. Java supports 3 types of comments as follows:
Do'stlaringiz bilan baham: