Java 100 Mock Questions-1
Java 100 Mock Questions-1
1.What is java?
• During the compilation the java program is converted into byte code(not machine
specific).
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
• A program in which source code is available to the general public for use and/or
modification from its original design at free of cost is called open source.
• JDeveloper(oracle) • RAD(IBM)
JDK:
JRE:
JVM:
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
Example:GreensTechnology
• Camel notation: First word's first letter should be a small letter, all the other
suceeding word's first letter should be a capital letter.
• Example:greensTechnology
Class:
• Class contains attributes(variables and methods) that are common to all the
objects created in a class.
Object:
• It wraps the data and code acting on data together in to a single unit.
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
• Accessing one class Properties in another class without multiple object creation.
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.
• Poly-many.
• Morphism-forms.
• Taking more than one forms is called polymorphism or one task implemented in
many ways.
---------------------------------------------------------------------------
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
When we have multiple methods with same method name but differs
• Class-name
• Method-same
------------------------------------------------------------------------
When you are not satisfied with the logic of your super class method,you can
create the same method(with exact same method name) in your sub-class and you can
write your required business logic.When you create object for sub-class,sub class method
only will get executed.so here child class method overriding parent class method.
• Method-same
• Argument-same
• Single Inheritance
• Multilevel Inheritance
• Multiple Inheritance
• Priority problem-When multiple parent classes has methods with same name and
arguments,compiler will not know which method should be called.
Multiple inheritance:
• More than one parent class directly supporting into same child class.
Multilevel inheritance:
• More than one parent class supporting into one child class in tree level structure.
• It is supported in java
• It will support only abstract method(without business logic), won't support non
abstract method(method with business logic)
Abstract class:
Interface:
Example : "greenstechnology".
• replace();
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
overriding.
variables.
• Parameterized constructor
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
• constructor is not directly called by your code, its called by memory allocation
and object initialisation in the run time.
To Restrict the object creation for the class the constructor kept as private
• The process of calling one constructor from another constructor with respect to
current object is called constructor chaining.
• No,we can't override the static method because it is part of a class rather than an object.
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
• All the instance of the class share the same static variable.
• When a method is declared as static,we need not create object to call the paticular
method.We can call as Classname.methodname()
• They use no instance variables and will usually take the input from the
parameters and perform action on it,then return some result.
51.What is mean by final keyword and what's happend when we declare final as in
class,method,variable?
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
Final:
Finally: • Code given inside finally block will always get executed whether exception
occurs or not.
54.What is Exception?
56.What are the difference between checked expection and unchecked expection?
• Throwable
• Exception
• Yes we can have try block without catch block.But in that case finally block must
be present.(There will be no syntax error)
• Possible but we will not able to handle the exception without catch block.
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
62.What are the differences between final finally and finalize in java?
Final:
• Finally:
• It’s a block of statement that definitely executes after the try catch block.
• Finalize:
Throw:
• Throw is a keyword, using which we can throw any any exception.This keyword
always given inside the method.
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
Throws:
• Exception
• ArithmeticException • NullPointerException
• InputMismatchException • ArrayIndexOutOfBoundExcepion
• StringIndexOutOfBoundExcepion • IndexOutOfBoundExcepion
• NumberFormatException
• IOException
•SQLException
• FileNotFoundException
• ClassNotFoundException
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
Advantage:
Disadvantages:
70.What is collection ?
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
ArrayList:
• Asynchronized
Vector:
• Synchronized
• Thread safe
LinkedList:
• Searching/retrieving is a worst.
ArrayList:
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
Eg:Collections.min(),Collections.max(),Collections.sort()
74.Describe the Collections type hierarchy ? What are the main interfaces ?
• TreeMap • ConcurrentHahMap
Set:
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
List:
• It allow duplicates.
HashSet:
TreeSet:
• By addAll() we can convert List into set.(all the elements in list will get added to set)
78.What is map?
• Key ignore the duplicate value and value allow the duplicates.
HashMap:
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
Hashtable:
• Synchronised(thread safe).
Set:
Map:
• Key ignore the duplicate value and value allow the duplicates.
• Yes,we can iterate the list using both normal and enhanced for loop.
• indexOf();
• get(); • lastIndexOf();
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
• Key ignore the duplicate value and value allow the duplicates.
• HashMap :k?,v?
• LinkedHashMap:k?,v?
• TreeMap :k?,v?
• HashTable :k?,v?
• Set<Entry<key,value>>
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
87.Write the methods to get the key only and value only?
• isHidden();
90.While creating a file if we not mention the format then under which format it will
save the file?
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.
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
Enumeration:
Iterator:
List Iterator:
Enumerator:
Iterator:
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
ListIterator:
Enumerator Methods:
• hasMoreElements(); • nextElement();
Iterator Methods:
ListIterator Methods:
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
• Statement which has control over the loop or program is called control
statements. • Example:if,if else,for,while,dowhile etc
if and if else
if else • executes the else part when the condition becomes false and
executes if part when condition becomes true.
Immutable string:
mutable string:
• removeAll() is a method , it is used to compare the 2 lists and remove all the
common values
• retainAll() is a method, it is used to compare both lists and retains only the
common values
Literal String:
• Its create a new memory every time even if it is a duplicate value(same value)
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us
Courses Java/Selenium/Python/JavaScript
Heap memory:
Static memory:
• Variables allocated on the stack are stored directly to the memory and access will
be very fast.
• java.lang
• collections.SynchronisedList(refName of array);
Location : 51-A, 2nd floor, Velachery Rd, Dhadeswaram Nagar, Velachery, Chennai, Tamil Nadu 600042
Follow us On: greens_softwaretraining_rxv Scan Here
GreensTechnologies Selenium To Reach Us