Core Java Interview Questions You'll Most Likely Be Asked
eBook - ePub

Core Java Interview Questions You'll Most Likely Be Asked

Vibrant Publishers

Partager le livre
  1. English
  2. ePUB (adapté aux mobiles)
  3. Disponible sur iOS et Android
eBook - ePub

Core Java Interview Questions You'll Most Likely Be Asked

Vibrant Publishers

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

Core Java Interview Questions You'll Most Likely Be Asked: Second Edition is your perfect companion to stand above the rest in today's competitive job market.

With this guide, you learn or refresh Core Java fundamentals and principles necessary for cracking the coding interview and acquaint yourself with real-life interview questions and strategies to reach the solutions. The Resume building tutorial and the Aptitude tests equip you to present yourself better even before the job interview.

This book is a complete course in itself to prepare for your dream Java job placement.

About the Series:

This book is part of the Job Interview Questions series that has more than 75 books dedicated to interview questions and answers for different technical subjects and HR round related topics.

This series of books is written by experienced placement experts and subject matter experts. Unlike comprehensive, textbook-sized reference guides, these books include only the required information for job search. Hence, these books are short, concise and ready-to-use by students and professionals.

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Core Java Interview Questions You'll Most Likely Be Asked est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Core Java Interview Questions You'll Most Likely Be Asked par Vibrant Publishers en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Informatik et Programmierung in JavaScript. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2021
ISBN
9781636510415

SECTION 01

CORE JAVA
JAVA 8
JAVA 9
HUMAN RESOURCE

CHAPTER 01

OOPs Concepts

001. Explain method overloading and method overriding.
Answer:
Method overloading occurs when there are two or more methods in a class with the same name but with different number/type of arguments. The following code demonstrates this:
public class Calculator {
public int add (int a, int b) {
return a+b;
}
public double add (double a, double b) {
return a+b;
}
public int add (int a) {
return a+a;
}
}
Method overriding occurs when there is a method in a sub–class that has the same name and number of arguments as a super–class method. The following code demonstrates this:
public class Animal {
public void saySomething () {
System.out.println(“I am an animal”);
}
}
public class Dog extends Animal {
public void saySomething () {
System.out.println(“I am a dog”);
}
}
002. Explain the benefits of OOPs.
Answer:
Following are the benefits of OOPs:
a. Reusability: OOPs principles like Inheritance, Composition and polymorphism help in reusing existing code
b. Extensibility: Code written using OOPs principles like Inheritance makes code extensible
c. Security: OOPs principles like encapsulation help to keep the data and the code that operates on the data together and makes the code secure
d. Simplicity: Java classes represent real world objects. This makes code very easy to understand
e. Maintainability: Code written using OOPs principles is easier to maintain
003. Write a code snippet that demonstrates encapsulation.
Answer:
Encapsulation refers to keeping the data and the code that operates on the data together as a single unit. Simply creating a class with private fields and public getter/setter methods is an example of encapsulation. The following code snippet demonstrates this:
public class Laptop {
private String memory;
public String getMemory () {
return memory;
}
public String setMemory (String newMemory){
memory = newMemory;
}
}
Here, there is a class called Laptop. It has a private field called memory and public getter and setter methods to access/modify the memory field. So, the memory field cannot be accessed directly outside the class, it can only be accessed via its getter/setter methods.
004. What are the types of inheritance relationships?
Answer:
Inheritance relationships specify how code can be reused. There are two types of inheritance relationships.
They are as follows:
a. IS–A
An IS–A relationship is implemented via inheritance, that is by creating a sub–class. Assume that, Camera is a subclass and Electronics is a super class. In that case, we can say that, Camera IS–A Electronic product
b. HAS–A
A HAS–A relation can be created via composition, that is by creating a field corresponding to another class. Assume that, inside the Camera class, there is an object called Battery. In that case, we can say that Camera HAS–A object called Battery
005. What is the best practice in declaring instance variables?
Answer:
Instance variable should always be declared as private. They should have public getter/setter methods. This helps to protect the instance variable as they can only be modified under the programmer’s control. This is as per the Encapsulation principle.
Declaring instance variables as public violates the encapsulation principle and poses a security issue. Public instance variables can be maliciously modified outside your class. If at all an instance variable needs to be accessed from a sub–class, it can be made protected.
006. What is a singleton class?
Answer:
A class which lets you create only one instance at any given time is termed a Singleton class. A Singleton class can be implemented via a private constructor and a public getter method. The following code demonstrates this.
public class MySingleton {
private static MySingleton mySingletonInstance;
private MySingleton () {
}
public static MySingleton getInstance () {
if (mySingletonInstance == null) {
mySingletonInstance = new MySingleton (); //
create the object only if it is null
}
return mySingletonInstance;
}
public void doSomething () {
System.out.println(“I am here....”);
}
public static void main(String a[]) {
MySingleton mySingleton = MySingleton.getInstance();
mySingleton.doSomething();
}
}
Here, a private constructor and a public getInstance method is defined. The getInstance checks if an instance exists. If an instance does not exist, it creates one using...

Table des matiĂšres