Why will you use Comparator and Comparable interfaces?

java.util.Comparator java.util.Comparator compares some other class’s instances. java.lang.Comparable java.lang.Comparable compares another object with itself. Differentiate between final, finally and finalize. The keyword is final. It is used for declaring a constant It prevents a class from producing subclasses. finally is a code.It always executes when the try block is finished, Unless System.exit() has been called.finalize() is a … Read more

What is RMI and how it is useful?

Remote method invocation is called RMI. One can work with remote object using RMI. It gives a impression that you are working with a object that resides within your own JVM though it is somewhere. The protocol used by RMI is RMI-IIOP Define a Collection API. The set of classes and interfaces supporting the operation … Read more

Number the bits, used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?

Unicode requires 16 bits ASCII require 7 bits. but it is usually represented as 8 bits. UTF-8 represents characters using 8, 16, and 18 bit patterns. UTF-16 uses 16-bit and larger bit patterns. Define reflection Reflection allows program related access to information about the fields, methods and constructors of loaded classes It use reflected fields, … Read more

What are the alternatives to inheritance?

Delegation is an alternative to inheritance. Delegation denotes that you include an instance of any class as an instance variable, and forward messages to the instance. It is safer than inheritance because it ceases you to think about forwarded message , because the instance is of a known class, rather than a new class, and … Read more

How can a collection object be sorted?

// Sort Collections.sort(list); // Sort case-insensitive Collections.sort(list, String.CASE_INSENSITIVE_ORDER); // SortReverse-order Collections.sort(list, Collections.reverseOrder ()); // Reverse-order sort case-insensitive Define local, member and a class variable. Within a method variables declared are called “local” variables. Variables declared in the class i.e not in any methods are “member” variables (global variables). Variables declared in the class i.e not … Read more