November 10, 2018

Sreekanth B

MuleSoft Most Frequently Asked Core Java Interview Questions Answers

What Is Oops?

Object oriented programming organizes a program around its data, i. e. , objects and a set of well defined interfaces to that data. An object-oriented program can be characterized as data controlling access to code.

What Are Class, Constructor And Primitive Data Types?

Class is a template for multiple objects with similar features and it is a blue print for objects. It defines a type of object according to the data the object can hold and the operations the object can perform. Constructor is a special kind of method that determines how an object is initialized when created. Primitive data types are 8 types and they are: byte, short, int, long, float, double, boolean, char.

What Is An Object And How Do You Allocate Memory To It?

Object is an instance of a class and it is a software unit that combines a structured set of data with a set of operations for inspecting and manipulating that data. When an object is created using new operator, memory is allocated to it.

What Is The Difference Between Constructor And Method?

Constructor will be automatically invoked when an object is created whereas method has to be called explicitly.

What Are Methods And How Are They Defined?

Methods are functions that operate on instances of classes in which they are defined. Objects can communicate with each other using methods and can call methods in other classes. Method definition has four parts. They are name of the method, type of object or primitive type the method returns, a list of parameters and the body of the method. A method’s signature is a combination of the first three parts mentioned above.

What Is The Use Of Bin And Lib In Jdk?

Bin contains all tools such as javac, appletviewer, awt tool, etc., whereas lib contains API and all packages.
MuleSoft Most Frequently Asked Core Java Interview Questions Answers
MuleSoft Most Frequently Asked Core Java Interview Questions Answers

How Many Ways Can An Argument Be Passed To A Subroutine And Explain Them?

An argument can be passed in two ways.

Passing by value: This method copies the value of an argument into the formal parameter of the subroutine.

Passing by reference: In this method, a reference to an argument (not the value of the argument) is passed to the parameter.

What Is The Difference Between An Argument And A Parameter?

While defining method, variables passed in the method are called parameters. While using those methods, values passed to those variables are called arguments.

How Would You Implement A Thread Pool?

The ThreadPool class is a generic implementation of a thread pool, which takes the following input Size of the pool to be constructed and name of the class which implements Runnable (which has a visible default constructor) and constructs a thread pool with active threads that are waiting for activation. once the threads have finished processing they come back and wait once again in the pool.

What Are The Advantages And Disadvantages Of Reference Counting In Garbage Collection?

An advantage of this scheme is that it can run in small chunks of time closely linked with the execution of the program. These characteristic makes it particularly suitable for real-time environments where the program can't be interrupted for very long time. A disadvantage of reference counting is that it does not detect cycles. A cycle is two or more objects that refer to one another. Another disadvantage is the overhead of incrementing and decrementing the reference count each time. Because of these disadvantages, reference counting currently is out of favor.

Why Java Is Said To Be Pass-by-value ?

When assigning an object to a variable, we are actually assigning the memory address of that object to the variable. So the value passed is actually the memory location of the object. This results in object aliasing, meaning you can have many variables referring to the same object on the heap.

What Are The Access Modifiers Available In Java?

Access modifier specify where a method or attribute can be used.

Public is accessible from anywhere.
Protected is accessible from the same class and its subclasses.
Package/Default are accessible from the same package.
Private is only accessible from within the class.

What Is The Difference Between A Switch Statement And An If Statement?

If statement is used to select from two alternatives. It uses a boolean expression to decide which alternative should be executed. The expression in if must be a boolean value. The switch statement is used to select from multiple alternatives. The case values must be promoted to an to int value.

What Are Synchronized Methods And Synchronized Statements?

Synchronized methods are methods that are declared with the keyword synchronized. thread executes a synchronized method only after it has acquired the lock for the method's object or class. Synchronized statements are similar to synchronized methods. It is a block of code declared with synchronized keyword. A synchronized statement can be executed only after a thread has acquired the lock for the object or class referenced in the synchronized statement.

What Are The Different Ways In Which A Thread Can Enter Into Waiting State?

There are three ways for a thread to enter into waiting state. By invoking its sleep() method, by blocking on I/O, by unsuccessfully attempting to acquire an object's lock, or by invoking an object's wait() method.

What Is The Difference Between Static And Non Static Variables ?

A static variable is associated with the class as a whole rather than with specific instances of a class. There will be only one value for static variable for all instances of that class. Non-static variables take on unique values with each object instance.

What Is The Difference Between Notify And Notifyall Method?

notify wakes up a single thread that is waiting for object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened. The choice is arbitrary and occurs at the discretion of the implementation. notifyAll Wakes up all threads that are waiting on this object's monitor. A thread waits on an object's monitor by calling one of the wait methods.

Subscribe to get more Posts :