May 11, 2019

Srikaanth

Datamatics Core Java Interview Questions Answers

What Is An Arrays?

Sometimes you will need to manipulate a series of related objects within an array object. Arrays let your programs work conveniently with a group of related objects. In short, an array simply lets you store and access a set of objects of the same type within the same variable. For example, you can use an array to keep track of grades for fifty students or to store a series of file names.

Even though Java arrays are similar in syntax to C/C++ arrays, they have subtle differences. In Java, an array is basically an object that points to a set of other objects or primitive data types. The only visible difference between arrays and objects is that arrays have a special syntax to make them behave like the arrays found in other languages. Unlike C and C++, however, Java arrays cannot change in size, nor can a program use an out-of-bound index with a Java array. Also, you declare and create arrays in Java very differently than in C/C++.

What Is Binary Search?

You know that you can find an element in an array by searching each element of the array one by one. Unfortunately, sequential searches are very inefficient for large arrays. If your array is sorted, you can use a binary search instead to locate a value within the array. A binary search repeatedly subdivides the array until it finds your desired element. For example, you have undoubtedly searched for a word in a dictionary. A sequential search is equivalent to searching each word one by one, starting from the very first word. If the word is much past the first page, this type of search is a very inefficient process.

A binary search is equivalent to opening a dictionary in the middle, and then deciding if the word is in the first half or second half of the book. You then open the next section in the middle and if the word is in the first half or second half of that section. You can then repeat this process of dividing the book in half until you find the word for which you are looking. If you have never tried, pick a word and try to find it in a dictionary using a binary search technique. You might be surprised at how few divisions it takes to get very close to the word you are looking for. A binary search is very efficient. However, the array must be sorted for it to work.

Can A Private Method Of A Superclass Be Declared Within A Subclass?

Sure. A private field or method or inner class belongs to its declared class and hides from its subclasses. There is no way for private stuff to have a runtime overloading or overriding (polymorphism) features.

What Is Quick Sort?

For large arrays, you need an efficient sorting technique. One of the most efficient techniques is the quick sort. The quick sort technique takes the middle element of an array and sub-divides the array into two smaller arrays. One array will contain elements greater than the middle value of the original array. Conversely, the other array will contain elements that are less than the middle value. The quick sort will repeat this process for each new array until the final arrays contain only a single element. At this point, the single element arrays are in the proper order, as shown below

What Is The Difference Between Final, Finally And Finalize?

 final—declare constant
 finally—handles exception
 Finalize—helps in garbage collection.

In System.out.println( ), What Is System, Out And Println?

System is a predefined final class, out is a PrintStream object and println is a built-in overloaded method in the out object.

What Is Meant By "abstract Interface"?

First, an interface is abstract. That means you cannot have any implementation in an interface. All the methods declared in an interface are abstract methods or signatures of the methods.

What Is The Difference Between Swing And Awt Components?

AWT components are heavy-weight, whereas Swing components are lightweight. Heavy weight components depend on the local windowing toolkit. For example, java.awt. Button is a heavy weight component, when it is running on the Java platform for Unix platform, it maps to a real Motif button.

Why Java Does Not Support Pointers?

Because pointers are unsafe. Java uses reference types to hide pointers and programmers feel easier to deal with reference types without pointers.

What Are Parsers? Dom Vs Sax Parser.

Parsers are fundamental xml components, a bridge between XML documents and applications that process that XML. The parser is responsible for handling xml syntax, checking the contents of the document against constraints established in a DTD or Schema.

What Is A Platform?

A platform is the hardware or software environment in which a program runs. Most platforms can be described as a combination of the operating system and hardware, like Windows 2000/XP, Linux, Solaris and MacOS.

What Is The Main Difference Between Java Platform And Other Platforms?

The Java platform differs from most other platforms in that it's a software-only platform that runs on top of other hardware-based platforms, The Java platform has two components

The Java Virtual Machine (Java VM).
The Java Application Programming Interface (Java API).

What Is The Java Virtual Machine?

The Java Virtual Machine is software that can be ported onto various hardware-based platforms.

What Is The Java Api?

The Java API is a large collection of ready-made software components that provide many useful capabilities, such as graphical user interface (GUI) widgets.

What Is The Package?

The package is a Java namespace or part of Java libraries. The Java API is grouped into libraries of related classes and interfaces; these libraries are known as packages.

What Is Native Code?

The native code is a code that after you compile it, the compiled code runs on a specific hardware platform.

Is Java Code Slower Than Native Code?

Not really. As a platform-independent environment, the Java platform can be a bit slower than native code. However, smart compilers, well-tuned interpreters, and just-in-time bytecode compilers can bring performance close to that of native code without threatening portability.

What Is The Serialization?

The serialization is a kind of mechanism that makes a class or a bean persistence by having its properties or fields and state information saved and restored to and from storage.

Datamatics Most Frequently Asked Core Java Interview Questions Answers
Datamatics Most Frequently Asked Core Java Interview Questions Answers
How To Make A Class Or A Bean Serializable?

By implementing either the java.io.Serializable interface or the java.io.Externalizable interface. As long as one class in a class's inheritance hierarchy implements Serializable or Externalizable, that class is serializable.

How Many Methods Are There In The Serializable Interface?

There is no method in the Serializable interface. The Serializable interface acts as a marker, telling the object serialization tools that your class is serializable.

How Many Methods Are There In The Externalizable Interface?

There are two methods in the Externalizable interface. You have to implement these two methods in order to make your class externalizable. These two methods are

readExternal() and
writeExternal().

Which Containers Use A Border Layout As Their Default Layout?

The Window, Frame and Dialog classes use a border layout as their default layout.

What Is Synchronization And Why Is It Important?

With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object's value. This often causes dirty data and leads to significant errors.

Subscribe to get more Posts :