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

Core Java Interview Questions You'll Most Likely Be Asked

Vibrant Publishers

Compartir libro
  1. English
  2. ePUB (apto para móviles)
  3. Disponible en iOS y Android
eBook - ePub

Core Java Interview Questions You'll Most Likely Be Asked

Vibrant Publishers

Detalles del libro
Vista previa del libro
Índice
Citas

Información del libro

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.

Preguntas frecuentes

¿Cómo cancelo mi suscripción?
Simplemente, dirígete a la sección ajustes de la cuenta y haz clic en «Cancelar suscripción». Así de sencillo. Después de cancelar tu suscripción, esta permanecerá activa el tiempo restante que hayas pagado. Obtén más información aquí.
¿Cómo descargo los libros?
Por el momento, todos nuestros libros ePub adaptables a dispositivos móviles se pueden descargar a través de la aplicación. La mayor parte de nuestros PDF también se puede descargar y ya estamos trabajando para que el resto también sea descargable. Obtén más información aquí.
¿En qué se diferencian los planes de precios?
Ambos planes te permiten acceder por completo a la biblioteca y a todas las funciones de Perlego. Las únicas diferencias son el precio y el período de suscripción: con el plan anual ahorrarás en torno a un 30 % en comparación con 12 meses de un plan mensual.
¿Qué es Perlego?
Somos un servicio de suscripción de libros de texto en línea que te permite acceder a toda una biblioteca en línea por menos de lo que cuesta un libro al mes. Con más de un millón de libros sobre más de 1000 categorías, ¡tenemos todo lo que necesitas! Obtén más información aquí.
¿Perlego ofrece la función de texto a voz?
Busca el símbolo de lectura en voz alta en tu próximo libro para ver si puedes escucharlo. La herramienta de lectura en voz alta lee el texto en voz alta por ti, resaltando el texto a medida que se lee. Puedes pausarla, acelerarla y ralentizarla. Obtén más información aquí.
¿Es Core Java Interview Questions You'll Most Likely Be Asked un PDF/ePUB en línea?
Sí, puedes acceder a Core Java Interview Questions You'll Most Likely Be Asked de Vibrant Publishers en formato PDF o ePUB, así como a otros libros populares de Informatik y Programmierung in JavaScript. Tenemos más de un millón de libros disponibles en nuestro catálogo para que explores.

Información

Año
2021
ISBN
9781636510415
Edición
1
Categoría
Informatik

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...

Índice