Monday, July 21, 2014

Basic Java - 2

In interviews, they might want to get your idea on re-usability concepts and how you will really re-use code from a design perspective.

What is an Abstract class ?
What is an interface ?
What are the differences ?
When you use Abstract class ? When you use interface ?
Can abstract class have constructors ?

Java is pass by value...

Try to swap the reference :)

Threads, wait, sleep, notify etc.

lock for static and non static method.


VMware questions

1. What is linked clone vm ?

Linked clone is made from a snapshot of a parent vm with virtual disks shared between the clone and the parent. This clone is dependent on the parent vm. It needs access to the parent vm. If there is no access to the parent vm, then the clone is powered off. The changes to the parent virtual disks will not affect the clone and vice versa. The changes are tracked based on delta disks per cloned vm.

2. What is storage vMotion ?
moving a vm from one host to another host without downtime to the users.
In this process the storage of the vm, resides in the initial host itself. This is called VMware vMotion.
sVMotion is storage vMotion where the vm is moved from one host to another host with no down time. In this process, the storage associated with the vm is also moved to the destination host.

3. Difference between linked clone and full clone
full clone is full clone, independent from the parent. It needs no access to the parent vm. It takes several minutes to get cloned based on the size of the parent vm.

linked clone needs access to parent vm, otherwise it is powered off. It is created swiftly. May have performance issues because disk space is shared

Tuesday, July 16, 2013

Basic Java

Java Blogs are millions in number. I wanted to write this blog, just to make it easy for myself during interview preparations and also a name tag of technical blog I would get out of it.

Java is a very easy language compared to C , C++. That is a wide opinion. Others feel Java is COBOL of modern age, used by all, but not so efficient. Opinions apart, most machines in the world Java byte-codes. So we learn Java and eventually end up as a developer primarily use Java.

Lets talk about initial phone interview questions.

Easy phone interview questions:

1. What is a Final class for ? Final method ? Final variable ?
1.1. What is Finally ?
1.2. Explain Finalize?
In other words, this question is famously know as, Final,Finally,Finalize
(I don't know how they are related !!!)

I am writing a class that contains lot of confidential information. No other person should be able to access the class without an object for it, which means, no other class should be able to just extend this class and use its methods or variables. I want to end the chain of this class, so I make it Final. No other class can extend it. Final class gives security to the program.

What if I have just a block of code that should be secured ? So we create a method and mark it as Final. So other classes can extend the class, but they cannot override (change/re-write) the Final method in their classes.

I don't even have a block of code to be secured, just a variable. So make it a Final variable. In this case, the variable cannot be changed once initialized.

Finally - This is a part of try-catch block. Finally is executed irrespective of the execution of try or catch block. If we feel like some part of code might throw some error, we put it in try block. If the block is not executing properly, or there is some error, we will catch that exception in catch block. So either try block is executed or catch block is executed. If we want something to be executed after both of them, we place it in finally block.

eg. We can give system shutdown there. We can give some killing jobs there. Clean up code can be there.
It is like switching off your stove after cooking anything.

One common question, if there is a break in try block, will finally get executed ? Yes. finally gets executed. Only System.exit() prevents finally from getting executed.

Finalize is garbage collection mechanism in Java. Java garbage collection can be done manually by using finalize method.