2. 1. Apart from providing details about the code, where else do you
think comments will help in java programming?
Comments help us to maintain the code and to find errors easily. Any explanation
regarding the variables or the class can be given inside comments. The program does
not get interrupted by the alternative code when e compile it.
3. Documentation comments are applied in large programs like a project or software
application. With its help of it, we can create the documentation API. Detailed and brief
information about classes, methods, and arguments is mentioned in the documentation
comment. These comments are placed between /** and */.
Generally, we use the javadoc tool to create documentation comments for a Java code.
2. You would’ve used the Java single-line comment and
multi-line comments many times in your code. What do
you know about Java documentation comments?
4. 3. What are the different data types of databases that are
used to store images and files in a database table?
BLOB: We can use this data type to store images and even audio.
It stores the binary type of data.
CLOB: It allows us to store files in a Java database. The data
stored here is present in character format.
There are two data types to store images and files in the java
database.
5. 4. List some scenarios where a
programmer might encounter the
NullPointerException.
Calling a variable that is not initialized.
Passing a null object as an argument for a method
Synchronizing an object that is a null
Making any kind of modifications in the data field with a null object.
Invoking a method that has a null object
Throwing a null object.
A programmer would encounter the NullPointerException in situations like:
6. 5. Elucidate on the relationship that is a “belong-to” type of
relationship.
In Java, the concept of Composition is associated with the “belong-to” type of relationship. Here,
one object is logically related to the other objects. This means the objects cannot exist in the
system’s scope in the absence of each other.
6. Name the four types of relationships in association and state an
example for each.
One-to-One relation: One professor is assigned to one department.
One-to-Many relation: One professor is assigned to multiple departments.
Many-to-One relation: Many professors are assigned to one department.
Many-to-Many relations: Many professors are assigned to work in many departments.
7. 7. It is obvious that any method that uses the static keyword is
referred to as a static method. What is the other way to find if a
method is static or not?
The static keyword is used to build methods that are present without considering the presence of
the objects. Therefore, such methods that exist regardless of whether or not the objects are
generated can be labeled as static methods.
8. What restrictions do you face in implementing the concept of the static
method?
Implementing static methods does not allow to use the of non-static data members or non-static
methods. It also applies vice-versa. Keywords like ‘this’ and ‘super’ cannot be used in a static
environment.
8. 9. Why is static binding called as early binding in Java?
The static binding is resolved during the compile time by the compiler. The methods like
static, private, and final complete their binding phase during the compile time itself.
Therefore, static binding is known as early binding.
10. What are the ways to obtain string input in java?
Using the nextLine() method present in the Scanner class.
Using the readLine() method present in the BufferedReader class.
We can also obtain input through the Scanner class next() method.
Moreover, the input can also be obtained via the command-line arguments of the main()
method.