1.
Who owns the Java now?
Correct Answer
C. Oracle Corporation
Explanation
Oracle Corporation owns Java now.
2.
One waiting strategy in Java is...
Correct Answer
A. Busy spinning
Explanation
Busy spinning is a waiting strategy in Java where a thread continuously checks for a certain condition to become true without yielding or sleeping. This strategy is used when the waiting time is expected to be very short and it is more efficient to keep the thread active rather than suspending it. The thread repeatedly executes a loop, checking the condition until it becomes true, at which point it can proceed with the next task. This approach avoids the overhead of context switching and thread resumption, making it suitable for situations where waiting time is minimal.
3.
What is the reason for Immutability in Java?
Correct Answer
D. For thread safety
Explanation
Immutability in Java is implemented to ensure thread safety. When an object is immutable, its state cannot be changed after it is created. This means that multiple threads can safely access and use the object without the risk of data corruption or inconsistency. Immutable objects are also useful in concurrent programming as they eliminate the need for synchronization mechanisms, improving performance and reducing the chance of bugs related to thread interference. Therefore, immutability is crucial in Java to guarantee thread safety.
4.
Which of these patterns cannot be use with Java?
Correct Answer
D. pHototype
Explanation
The correct answer is Phototype because there is no pattern called "Phototype" in Java. The other options mentioned, MVC, GOF, and Singleton, are all well-known design patterns that can be used with Java.
5.
In Java, read-write lock uses how many lock(s)?
Correct Answer
B. 2
Explanation
In Java, a read-write lock uses two locks: one for reading and one for writing. This allows multiple threads to read the data simultaneously, but only one thread can write to the data at a time. This ensures that the data remains consistent and avoids conflicts between readers and writers.
6.
When string is Immutable, then...
Correct Answer
A. Strings have been cached in string pool
Explanation
When a string is immutable, it means that its value cannot be changed after it is created. In Java, strings are stored in a string pool, which is a cache of unique string literals. When a new string is created, the JVM first checks if it already exists in the string pool. If it does, the existing string reference is returned instead of creating a new object. This improves performance and saves memory. Therefore, the correct answer is that strings are cached in the string pool.
7.
Which of these is not an object-oriented programming?
Correct Answer
C. Beautification
Explanation
Beautification is not an object-oriented programming concept. Polymorphism, encapsulation, and inheritance are all fundamental principles in object-oriented programming. Polymorphism allows objects of different classes to be treated as objects of the same class, encapsulation is the practice of hiding internal data and methods within a class, and inheritance allows a class to inherit properties and methods from another class. However, beautification does not relate to the principles or concepts of object-oriented programming.
8.
Which of these methods will you use to protect your code against third-parties?
Correct Answer
C. Code against interface
Explanation
Code against interface is a method used to protect code against third-parties. By coding against an interface instead of a concrete implementation, the code becomes more flexible and resistant to changes made by third-party libraries or components. This approach allows for easier maintenance and updates, as the code can adapt to different implementations without breaking. It also promotes modularity and separation of concerns, making the code more robust and easier to test.
9.
One of the principles for designing Java is...
Correct Answer
A. Portability
Explanation
One of the principles for designing Java is portability. This means that Java programs can run on any platform or operating system without the need for modifications. Java achieves portability through the use of bytecode, which is a platform-independent representation of the program that can be executed by a Java Virtual Machine (JVM). This allows developers to write code once and run it anywhere, making Java a popular choice for building cross-platform applications.
10.
Executing SQL queries will do one of the following, what is it?
Correct Answer
D. Improve performance
Explanation
Executing SQL queries can improve performance because SQL is designed to efficiently retrieve and manipulate data stored in a database. By using SQL queries, we can retrieve only the necessary data, perform complex operations on the database server side, and optimize the execution plan for better performance. This can lead to faster data retrieval, reduced network traffic, and improved overall application performance.