マツシタのお勉強

Knowledges about Java 【Interview preparation】

Introduction

This article is for my preparation of technical interview. And this focuses on programming language “Java”.

final keyword

The final keyword in Java has different meaning depending on whether it is applied to a variable, class or method.

Variable : The value cannot be changed once initialized.
Method : The method cannot be overridden by a subclass.
Class : The class cannot be subclassed.

finally keyword

finally keyword is used with a try/catch block. The finally block will be executed after the try and catch blocks.

Overloading vs. Overriding

Overloading is the mechanism that we can define some functions with same name if the arguments of the function are different.

Overriding is the mechanism that we can override the function which is defined in super class.

Collection Framework

ArrayList

An ArrayList is a dynamically resizing array, which grows as you insert elements.

Vector

A vector is very similar to ArrayList except that it is synchronized. So, when the list is accessed at same time, we should not use ArrayList.

LinkedList

In LinkedList case, each element has the next element as a property. So we can add or remove an element speedy.

HashMap

We can store value with key by HashMap.

HashTable

HashTable is similar to HashMap except that it is synchronized.

TreeMap

TreeMap is a one of the Map structures. The feature is that keys are sorted. It is ascending order.

TreeMap has node which has left, right, and parent node internally. So it has binary tree.

LinkedHashMap

TreeMap is a one of the Map structures. The feature is that the order that we add elements into the map is kept.