Interview Prep Flashcards
What is Java platform independence?
Java platform independence means that this programming language can run on different platforms or OS without any changes, which becomes possible with bytecode. The original code of Java is converted into bytecode to adapt it for a specific machine. Bytecode is transmitted to Java Virtual Machine (or simply JYM) that is located in the RAM of any OS. JYM detects the bytecodes and transforms them into the native machine code.
What is an RDBMS?
RDBMS stands for Relational Data Base Management System, which is based on the relational model of the database system. It includes numerous tables that have their own primary key and are used to store the data using columns and rows. Typical examples of the RDBMS are systems like SQL, MS SQL Server, IBM DB2, ORACLE, My-SQL, Microsoft Access, and others.
What are the basic access specifiers for Java classes?
Access specifiers (also known as access modifiers) are the specific keywords used before a class name to determine the access scope. They’re mostly used for defining the visibility of classes, variables, interfaces, constructors, methods, etc. In Java, there are 4 types of access modifiers:
Private - variables that can be accessed only from the same class they belong to;
Public - methods and variables that can be accessed by any other classes in the project;
Protected - variables that can be accessed within the same set of classes and subclasses of any other packages;
Default - methods and variables that can be accessed only from the same package (not from the native one).
What are loops in Java and what are the 3 types of loops?
Java loop repeats a sequence of instructions until a particular condition is met. There are three types of loops in Java: for, while, and do-while.
What is the difference between fail-fast and fail-safe iterators?
Fail-fast iterators perform directly on the collection, which means they fail as soon as the definition of the collection has been changed during iteration.
Unlike the previous ones, fail-safe iterators function directly on a collection’s copy, thus they do not throw any exception if the collection has been changed during iteration.
What is the MVC design pattern?
MVC (also known as Model-View-Controller) is an app design tool that divides the application into 3 parts:
Model - stands for the app data
View - data representation on a screen
Controller - operates the list of processes and responds to the actions, that sometimes can change the model
What is Core Java?
Core Java is a general term used by Sun Microsystems to define a basic edition of Java (J2SE), used for the other editions created. Core Java is mainly used for building desktop and server-based apps, mostly because of its benefits as the fast and a highly-secure scripting language.
What are the 4 types of Java platforms?
Being a particular environment for the Java programming language, there are 4 different platform types for Java:
Java SE or Java Standard Edition
Java EE or Java Enterprise Edition
Java ME or Java Micro Edition
Java FX
What is the difference between transient and volatile variables in Java?
The main difference between transient vs volatile variables is that transient variables are utilized to prevent serialization while volatile variables are utilized to provide alternative synchronization in Java.
What’s the difference between a ClassNotFoundException and NoClassDefFoundError?
ClassNotFoundException is an exception that occurs when the class file for a requested class can’t be found on the classpath.
NoClassDefFoundError is an error that occurs when the class file existed at runtime but can’t be turned into a Class definition for some reason.
What’s the difference between ‘sleep ( )’ and ‘wait ( )’ methods in Java?
‘sleep ( )’ is a blocking operation that keeps either hold on the monitor or the lock on the shared object for a set amount of milliseconds and is commonly used for polling or certain results tracking at a set time.
‘wait ( )’ pauses the thread for the set amount of time or enables it after receiving approval from the other thread without locking the shared object or holding on to the monitor.
When ‘finally’ block is executed in Java?
The ‘finally’ block is mostly applied for putting the important codes like the clean-up code, for example when the file or connection needs closing. The ‘finally’ block is executed when an exception is thrown from a ‘try’ block that does not have a ‘catch’ block. It is executed even in cases when an exception is thrown or propagated to the calling code block.
What is the Java ClassLoader?
ClassLoader is the “deepest” mechanism in Java, which allows you to intervene practically into the core of the Java Virtual Machine (JVM) while remaining within the framework of Java programming. ClassLoader provides loading the classes from the local file system, remote file system, or web.
There are 3 types of ClassLoader in Java:
Bootstrap ClassLoader: Responsible for loading standard Java API files rt.jar from folder
Extensions ClassLoader: Manages loading jar files from the folder.
System Class Loader: Operates loading jar files from the specific path in the CLASSPATH environment
Can you use == on enum?
Yes, as the enums represent a set of constants like unchangeable variables or final variables, which ensure that you’ll have only one case of the constants used in the JVM. They have close instance controls which allow using == for the instances comparison. Furthermore, the ‘==’ operator provides compile-time and run-time safety.
What is composition in Java?
Composition in Java stands for code reusing. Basically, the composition is used as a part-of or ‘has-a’ relationship that helps to ensure the code reusability in the program. In other words, that’s a technique that assists in describing the reference between two or more classes. The composition between two entities is marked as done when an object contains a composed object, and the last one can exist within another entity.
What is a static import?
A static import is a method used in the Java development process, which allows various members (like fields and methods), scoped within their container classes as public static, to be employed in Java code without indicating the exact class in which the field has been defined. This method enhances the code readability and gets direct access to the static members.
What is method overloading in Java?
Method overloading in Java stands for a feature that enables a class to have more than one method with the same name if their argument lists are different. It has some similar points to the constructor overloading. There are 3 different ways in which you can overload a method:
by number of parameters
by the data type of parameters
by the sequence of the data type of parameters
What is method overriding in Java?
Method overriding in Java stands for a feature that allows a subclass or child class to complete a specific implementation of a method that has been done by one of its superclasses or parent classes. One of the benefits of this method is that it assists in defining a specific class type behavior so that a subclass can use a parent class method based on its type.
What does the Final Keyword in Java mean?
The final keyword defines the entity which can be assigned only once and can’t be modified in the future. Once it’s been set, it can’t change its value anymore, for instance in the functions. The entity defined by the final keyword can be a variable, a class, a method, etc.
What are OOPs concepts in Java?
The OOPs concepts stand for Object-Oriented Programming in Java and cover the following elements: class, object, encapsulation, inheritance, polymorphism, and abstraction. All these assist in ensuring the application’s reusability, security, and flexibility, and allows developers to create the working methods and variables, then reuse them all or part of them without compromising the system security.
Does Java have a static class?
1 Declare the class final to prevent the class extension and make it static
You can’t build the advanced class static but you can enhance its performance in the next steps:
#2 Set up the private constructor
#3 Configure the members and functions of the class static as well
What does the GetMethod of HashMap do in Java?
HashMap is constructed using the hash table data structure. Basically, it employs the ‘hashCode ( )’ method to compute hash code to find the bucket location on the underlying array and the ‘equals ( )’ method to detect the object in the same bucket in case of a collision.
What is the Difference between JDK and JRE?
Java Runtime Environment (also known as JRE) stands for a Java Virtual Machine (or JVM), the programming environment where the Java programs are being executed. It also covers the browser plugins for the advanced applet execution.
Java Development Kit (also known as JDK) is a much more complex, full-stack Software Development Kit for Java programming language which includes the JRE, various compilers, and a list of tools (for instance, JavaDoc or Java Debugger). JDK is targeted at developing, compiling, and executing different Java apps.
What is the meaning of Spring beans?
The Spring beans are the objects that form the keystone of your application and are controlled by the Spring IoC container. A so-called “bean” is an object that is instantiated, assembled, and managed in any possible option by a Spring IoC container. The Spring beans are formed with the configuration metadata that is supplied to the container.
For instance, you can always meet their definitions in the XML form: