Project Management Professional: Core Java Interview Questions!

Tuesday, July 21, 2020

Core Java Interview Questions!


12.What are different ways of object creation in Java ?

Ans. Using new operator - new xyzClass()


Using factory methods - xyzFactory.getInstance( )


Using newInstance( ) method - (Class.forName(xyzClass))emp.newInstance( )


By cloning an already available object - (xyzClass)obj1.clone( )


13.What is a Lambda Expression ? What's its use ?

Its an anonymous method without any declaration. 

Lambda Expression are useful to write shorthand Code and hence saves the effort of writing lengthy Code. 

It promotes Developer productivity, Better Readable and Reliable code.

14.Which are the different segments of memory ?

Ans. 1. Stack Segment - Contains primitives, Class / Interface names and references.


2. Heap Segment - Contains all created objects in runtime, objects only plus their object attributes (instance variables), Static variables are also stored in heap.


3. Code Segment - The segment where the actual compiled Java bytecodes resides when loaded



No comments: