1 / 8

Core Java Interview Questions with Answers

https://firstcode.school/core-java-interview-questions-with-answers/

Sudhanshi
Download Presentation

Core Java Interview Questions with Answers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Core Java Interview Questions with Answers

  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. 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? 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.

  4. 3. What are the different data types of databases that are used to store images and files in a database table? There are two data types to store images and files in the java database. 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.

  5. 4. List some scenarios where a programmer might encounter the NullPointerException. A programmer would encounter the NullPointerException in situations like: 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.

  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.

More Related