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

Core Java Interview Questions You'll Most Likely Be Asked

Vibrant Publishers

Buch teilen
  1. English
  2. ePUB (handyfreundlich)
  3. Über iOS und Android verfĂŒgbar
eBook - ePub

Core Java Interview Questions You'll Most Likely Be Asked

Vibrant Publishers

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

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.

HĂ€ufig gestellte Fragen

Wie kann ich mein Abo kĂŒndigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kĂŒndigen“ – ganz einfach. Nachdem du gekĂŒndigt hast, bleibt deine Mitgliedschaft fĂŒr den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich BĂŒcher herunterladen?
Derzeit stehen all unsere auf MobilgerĂ€te reagierenden ePub-BĂŒcher zum Download ĂŒber die App zur VerfĂŒgung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die ĂŒbrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den AboplÀnen?
Mit beiden AboplÀnen erhÀltst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst fĂŒr LehrbĂŒcher, bei dem du fĂŒr weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhĂ€ltst. Mit ĂŒber 1 Million BĂŒchern zu ĂŒber 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
UnterstĂŒtzt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nÀchsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist Core Java Interview Questions You'll Most Likely Be Asked als Online-PDF/ePub verfĂŒgbar?
Ja, du hast Zugang zu Core Java Interview Questions You'll Most Likely Be Asked von Vibrant Publishers im PDF- und/oder ePub-Format sowie zu anderen beliebten BĂŒchern aus Informatik & Programmierung in JavaScript. Aus unserem Katalog stehen dir ĂŒber 1 Million BĂŒcher zur VerfĂŒgung.

Information

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

Inhaltsverzeichnis