Which of the following keywords is used to create a new object in Java?
- createObject
- new
- newInstance
- newObject
In Java, the new keyword is used to create a new object. When you want to instantiate a class and create an object, you use the new keyword followed by the class constructor. For example, ClassName obj = new ClassName();. The other options are not used to create objects in Java.
Loading...
Related Quiz
- What is the primary purpose of using Callable in Java?
- Consider a scenario where you want to invert the sign of a numeric value only if a particular boolean condition is true. How can unary operators be utilized to achieve this without using an if statement?
- Consider building a microservice handling requests from various clients and other microservices. How would you implement socket programming for non-blocking, asynchronous I/O and high throughput?
- Consider a scenario where an application retrieves a large amount of data from a database and displays it in a UI paginated form. How would you efficiently manage and optimize data retrieval and display using JDBC?
- Which of the following concepts allows Java objects to be initialized with actual data when they are created?