What will be the output of the following code snippet: System.out.println(10 + 20 + "Hello" + 30 + 40);?

  • 100200Hello3040
  • 1020Hello3040
  • 5070Hello
  • Hello10203040
In Java, when you use the + operator with both numbers and strings, it performs left-to-right addition. So, the numbers are added first, and then the result is concatenated with the strings. The correct output is "1020Hello3040."

The “effectively final” concept in the context of Lambda expressions refers to ________.

  • Variables that are static
  • Variables that are unused
  • Variables that don't change
  • Variables with final keyword
In the context of Lambda expressions, "effectively final" refers to variables that are not supposed to change after they are initially assigned a value. Lambda expressions can capture and use local variables from their surrounding scope, but these variables must be effectively final, meaning they are not modified after being captured by the lambda. This is to ensure the consistency of captured variables in the lambda's behavior.

To check whether the socket is bound, the ________ method can be used.

  • boundStatus()
  • checkBound()
  • isBound()
  • verifySocketBound()
In Java, you can use the isBound() method to check whether a socket is bound or not. This method returns true if the socket is bound, otherwise false.

Which method is typically overridden to handle an event in JavaFX?

  • handle()
  • handleEvent()
  • init()
  • start()
In JavaFX, to handle an event, you typically override the handle() method. This method is part of the EventHandler interface, and you provide your custom event-handling logic within it. The other options, such as start(), are methods used for different purposes in JavaFX applications.

In which scenario would you choose an abstract class over an interface?

  • When you want to achieve complete abstraction and hide the implementation details of a class.
  • When you want to define constants and static methods that are common to a group of related classes.
  • When you want to ensure multiple inheritance of behavior without worrying about method implementation conflicts.
  • When you want to provide a common base class with some shared functionality and allow derived classes to implement additional methods.
You would choose an abstract class over an interface when you want to provide a common base class with some shared functionality and allow derived classes to implement additional methods. Abstract classes can have both abstract and concrete methods, making them suitable for situations where you need to provide a common structure along with partial implementation.

What is the main disadvantage of the Bubble Sort algorithm in terms of performance?

  • It has a time complexity of O(n^2) in the worst case, making it inefficient for large datasets.
  • It is not a stable sorting algorithm, leading to unpredictable results when sorting objects with equal keys.
  • It is not an in-place sorting algorithm, which means it requires additional memory for sorting.
  • It requires additional memory space to perform sorting, increasing its space complexity.
The main disadvantage of Bubble Sort is its worst-case time complexity of O(n^2), which makes it inefficient for sorting large datasets. It is a comparison-based sorting algorithm, and its performance degrades significantly as the dataset size increases. Its stability and in-place sorting characteristics are not the primary factors affecting its performance.

To access or modify the private fields in a class, you should use ________ methods.

  • accessor
  • constructor
  • mutator
  • public
To access or modify private fields in a class, you should use "mutator" methods, also known as setter methods. These methods are designed to set or modify the private field values, maintaining control over access.

The method overriding is also known as ________ time polymorphism.

  • compile-time
  • dynamic
  • runtime
  • static
Method overriding is a form of polymorphism that occurs at runtime, making it dynamic polymorphism. It allows the actual method to be determined at runtime based on the object's type, which is why it's also known as runtime polymorphism.

In a class instance, synchronized blocks can be used to avoid locking the entire method and only lock ________.

  • the class instance
  • the instance itself
  • the method
  • the thread
In Java, synchronized blocks allow you to lock specific portions of a method rather than locking the entire method. By using synchronized blocks, you can choose what specific data or code you want to protect from concurrent access by specifying the object that should serve as the lock, commonly referred to as "the method's ________."

The method ________ is used to execute SQL for DDL statements using JDBC.

  • executeDDL()
  • executeQuery()
  • executeStatement()
  • executeUpdate()
In JDBC, the method executeUpdate() is used to execute SQL statements that perform Data Definition Language (DDL) operations, such as creating, altering, or dropping database objects. It returns an integer representing the number of rows affected by the statement. executeQuery() is used for retrieving data, not DDL statements.