CORE JAVA QnA
CORE JAVA QnA
1.What is java?
• Java is a simple and most widely used programming language.
• Java is fast,reliable and secure
18.What are the ways to access the methods /data from another class?
• We can access the another class methods either by creating object or using
extends keyword.
51.What is mean by final keyword and what's happened when we declare final as in
class,method,variable?
• Final is a non access modifier applicable to a variable, method or a class.
• When a variable is declared with final keyword,its value can't be modified.
• When a method is declared as final we can prevent method overriding.
• When a class is declared as final we can prevent inheritance.
54.What is Exception?
• Exception is an unexpected event which when occurs in a program,your program will
terminate
abnormally.
• We can avoid this abnormal termination using exception handling
mechanisms(try,catch,finally,throw,throws)
56.What are the difference between checked exception and unchecked exception?
Unchecked exception:
-------------------------
• It will occur at the Run time.
Checked exception:
----------------------
• Checked exception will occur at the Compile time.
62.What are the differences between final finally and finalize in java?
Final:
-----
• A final class variable whose value cannot be changed.
• A final method is declared in class level, they cannot be inherited.
• A class declared as final can't be inherited.
Finally:
--------
• It’s a block of statement that definitely executes after the try catch block.
• Exception occurs or not,finally block always get executed.
Finalize:
---------
• It will clean up unused memory space.
70.What is collection ?
• It will support storage of multiple values with dissimilar data types.
• It is dynamic memory allocation.
• No memory wastage like array.
74.Describe the Collections type hierarchy ? What are the main interfaces ?
Collection:
------------
• List
• Set
Map----doesnt come under collection,it is a separate interface in java
Hierarchy:
-----------
List:
----
• ArrayList
• LinkedList
• Vector
Set:
----
• Hashset
• LinkedHashSet
• Treeset
Map:
----
• HashMap
• LinkedHashMap
• Hashtable
• TreeMap
• ConcurrentHahMap
78.What is map?
• It is key and value pair.
• Here key+value is one entry.
• Key ignore the duplicate value and value allow the duplicates.
87.Write the methods to get the key only and value only?
• For key only keySet() method is used.
• For value only values() method is used.
90.While creating a file if we not mention the format then under which format it
will save the file?
• If we do not mention the file format it will automatically take format as file.
91.What are the difference between append and updating the file?
For updating the file:
---------------------
It will replace the old contents of the file.
For appending the file:
-----------------------
It will add the contents at the end of the file.