Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Java Interview Questions Cheat Sheet, Cheat Sheet of Java Programming

Useful cheat sheet with Java Interview Questions

Typology: Cheat Sheet

2019/2020
On special offer
30 Points
Discount

Limited-time offer


Uploaded on 10/09/2020

amlay
amlay ๐Ÿ‡บ๐Ÿ‡ธ

4.1

(19)

384 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Java Interview Questions Cheat Sheet
by sdm7306 via cheatography.com/51374/cs/14061/
Main Features of Java
Object Oriented
Simple
Platform Indepe๎˜ndent
Secure
Robust
Portable
Multit๎˜hreaded
Distri๎˜buted
Principles of OOP
Abst๎˜r
ac๎˜tion
Abstra๎˜ction means using simple
things to represent complexity using
object, classes, and variables.
Enca๎˜p
su๎˜lat๎˜i
on
This is the practice of keeping fields
within a class private, then providing
access to them via public methods.
Itโ€™s a protective barrier that keeps the
data and code safe within the class
itself.
Inhe๎˜rit๎˜
ance
It lets progra๎˜mmers create new
classes that share some of the
attributes of existing classes. This lets
us build on previous work without
reinve๎˜nting the wheel.
Poly๎˜m
or๎˜phis
m
Polymo๎˜rphism refers to any entity
whether it is a method or a
constr๎˜uctor or an operator which takes
many forms or can be used for
multiple tasks.
Multit๎˜hreaded Progra๎˜mming
Multit๎˜hreaded progra๎˜mming is one of the key
features of java which allows multiple threads
to execute their task simult๎˜ane๎˜ously.
There are two ways to create threads in
Java
a) by extending the Thread class
b) by implem๎˜enting the Runnable interface
Final, Finally, Finalize
Final Makes a variable, method, or class
unchan๎˜geable.
Fina๎˜l
ly
Exception handling after success or
failure during a try catch block.
Fina๎˜l
ize
Called by the garbage collector on an
object when garbage collection
determines that there are no more
references to the object.
Inheri๎˜tance
Inheri๎˜tance is one of the key principle of object
oriented progra๎˜mming. Through inheri๎˜tance,
one class can inherit the properties of another
class. The class from which properties are
inherited is called super class and the class to
which properties are inherited is called sub
class.
Does Java support multiple inheri๎˜tan๎˜ce?
Java supports multiple inheri๎˜tance but only
through interf๎˜aces. That means a class can
implement more than one interfaces but can
not extend more than one class.
Constr๎˜uctor & Method Overlo๎˜ading
A class can have any number of constr๎˜uctors.
These constr๎˜uctors will have different list of
arguments. It is called constr๎˜uctor
overlo๎˜ading. Constr๎˜uctor overlo๎˜ading provides
different ways to instan๎˜tiate a class.
If a class has more than one method with same
name but with different list of arguments, then it
is called method overlo๎˜ading.
Overriding
If a super class method is modified in the sub
class then it is called method overri๎˜ding.
Abstract Classes
An abstract class is a class which cannot be
instan๎˜tiated. An abstract class is used by
creating an inheriting subclass that can be
instan๎˜tiated. An abstract class does a few
things for the inheriting subclass:
1.๎˜Define methods which can be used by the
inheriting subclass.
2.๎˜Define abstract methods which the inh eriting
subclass must implement.
3.๎˜Provide a common interface which all ows the
subclass to be interc๎˜hanged with all other
subcla๎˜sses.
Exception Handling
try The code to be monitored for
exceptions will be kept in this block.
catch If any exceptions occurred in try block,
those exceptions will be caught by this
block.
fina๎˜ll
y
This block will be always executed
whether exception is raised or not and
raised exceptions are caught or not.
Checked & Unchecked Exceptions
Chec๎˜ked Known and checked at compile
time.
Unch๎˜eck
ed
Known at Runtime, unknown at
compile time.
Static & Non-Static Methods
Static method is common to all instances of a
class. Static methods are stored in the class
memory. Where as non-s
๎˜
tatic methods are
stored in the object memory. Each instance of a
class will have their own copy of non-static
methods.
Synchr๎˜oni๎˜zation
Synchr๎˜oni๎˜zation is a way of contro๎˜lling the
access of a method or a block by multiple
threads. Only one thread can enter into a
method or a block which has been declared as
synchr๎˜onized. Synchr๎˜oni๎˜zation is one of the
way to achieve thread safety.
By sdm7306
cheatography.com/sdm7306/
Published 21st December, 2017.
Last updated 21st December, 2017.
Page 1 of 2.
Sponsored by CrosswordCheats.com
Learn to solve cryptic crosswords!
http://crosswordcheats.com
pf2
Discount

On special offer

Partial preview of the text

Download Java Interview Questions Cheat Sheet and more Cheat Sheet Java Programming in PDF only on Docsity!

Java Interview Questions Cheat Sheet

by sdm7306 via cheatography.com/51374/cs/14061/

Main Features of Java Object Oriented Simple Platform Independent Secure Robust Portable Multithreaded Distributed Principles of OOP Abstr action Abstraction means using simple things to represent complexity using object, classes, and variables. Encap sulati on This is the practice of keeping fields within a class private, then providing access to them via public methods. Itโ€™s a protective barrier that keeps the data and code safe within the class itself. Inherit ance It lets programmers create new classes that share some of the attributes of existing classes. This lets us build on previous work without reinventing the wheel. Polym orphis m Polymorphism refers to any entity whether it is a method or a constructor or an operator which takes many forms or can be used for multiple tasks. Multithreaded Programming Multithreaded programming is one of the key features of java which allows multiple threads to execute their task simultaneously. There are two ways to create threads in Java a) by extending the Thread class b) by implementing the Runnable interface Final, Finally, Finalize Final Makes a variable, method, or class unchangeable. Final ly Exception handling after success or failure during a try catch block. Final ize Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. Inheritance Inheritance is one of the key principle of object oriented programming. Through inheritance, one class can inherit the properties of another class. The class from which properties are inherited is called super class and the class to which properties are inherited is called sub class. Does Java support multiple inheritance? Java supports multiple inheritance but only through interfaces. That means a class can implement more than one interfaces but can not extend more than one class. Constructor & Method Overloading A class can have any number of constructors. These constructors will have different list of arguments. It is called constructor overloading. Constructor overloading provides different ways to instantiate a class. If a class has more than one method with same name but with different list of arguments, then it is called method overloading. Overriding If a super class method is modified in the sub class then it is called method overriding. Abstract Classes An abstract class is a class which cannot be instantiated. An abstract class is used by creating an inheriting subclass that can be instantiated. An abstract class does a few things for the inheriting subclass:

1. Define methods which can be used by the inheriting subclass. 2. Define abstract methods which the inheriting subclass must implement. 3. Provide a common interface which allows the subclass to be interchanged with all other subclasses. Exception Handling try The code to be monitored for exceptions will be kept in this block. catch If any exceptions occurred in try block, those exceptions will be caught by this block. finall y This block will be always executed whether exception is raised or not and raised exceptions are caught or not. Checked & Unchecked Exceptions Checked Known and checked at compile time. Uncheck ed Known at Runtime, unknown at compile time. Static & Non-Static Methods Static method is common to all instances of a class. Static methods are stored in the class memory. Where as non-static methods are stored in the object memory. Each instance of a class will have their own copy of non-static methods. Synchronization Synchronization is a way of controlling the access of a method or a block by multiple threads. Only one thread can enter into a method or a block which has been declared as synchronized. Synchronization is one of the way to achieve thread safety. By sdm cheatography.com/sdm7306/ Published 21st December, 2017. Last updated 21st December, 2017. Page 1 of 2. Sponsored by CrosswordCheats.com Learn to solve cryptic crosswords! http://crosswordcheats.com

Java Interview Questions Cheat Sheet

by sdm7306 via cheatography.com/51374/cs/14061/

Garbage Collection Removing unwanted objects or abandoned objects from the memory is called garbage collection. Garbage collection is done automatically in java. You need not to remove the unwanted objects explicitly. Garbage collector thread does this for you. Cloning Cloning is a process of creating an exact copy of an existing object in the memory. Cloning may be shallow or deep. In java, clone() method is used to create a clone of an object. Interfaces A Java interface is a bit like a class, except a Java interface can only contain method signatures and fields. An Java interface cannot contain an implementation of the methods, only the signature (name, parameters and exceptions) of the method. You can use interfaces in Java as a way to achieve polymorphism. By sdm cheatography.com/sdm7306/ Published 21st December, 2017. Last updated 21st December, 2017. Page 2 of 2. Sponsored by CrosswordCheats.com Learn to solve cryptic crosswords! http://crosswordcheats.com