US IT recruiter

Interview questions -2

US IT recruiter

Design principles

SOLID
S: Single Responsibility Principle – > A class should have one responsibility only
O: Open-Closed Principle -> It should be open for extensions but close for changes.
L: Liskov Substitution Principle -> A subclass should be substitutable for the parent class
I: Interface Segregation Principle -> Make small interfaces for small contracts. Never implements an interface where we don’t implement all functions.
D: Dependency Inversion Principle -> High-level module must not depend on the low-level module, but they should depend on abstractions.

OOPS:
Encapsulation: Encapsulation means wrapping up data and member function (Method) together into a single unit i.e. class. Here we hide the data by making variables private and expose only public methods.
Data Abstraction: Using abstract class or Interface we express the intent of the class rather than the actual implementation.
Polymorphism : (Many forms) It is again categorized into two types:
Method overloading, also called as Static polymorphism , where two or more methods have the same name but have a different set of parameters.
Method overriding also called as Dynamic polymorphism, where subclass and parent class have same method name with same arguments.
Inheritance: Inheritance allows a class to acquire the properties and behavior of the parent or superclass. This helps to reuse and enhance the existing code.

Design patterns types:
Creational Patterns
Behavioral Patterns
Functional Patterns

Singleton: creational pattern and it restricts to have only one instance of object for the application.
Drawbacks: May be broken if the application is on multiple JVMs
Enums are a singleton and easy to manage. The only issue is that it doesn’t allow lazy initialization.
Implement singleton class with Serialization: here we will get another instance when we deserialize.
To fix this issue, we need to implement
protected Object readResolve() {
return getInstance();
}

Factory pattern : It hides the creational logic and has a more decoupled code.
Builder pattern can be used to create complex objects.
Builder vs Factory Pattern: Builder pattern is the extension of Factory pattern wherein the Builder class builds a complex object in multiple steps.
Observer pattern: This behavioral pattern is used when we want to know or notified the state of object. The object is called subject and all dependants are called as Observers.
Decorator pattern : Add additional functionality to a particular object at runtime
Facade Pattern: hides the complexities of the system and provides an interface to the client using which the client can access the system

JDK design pattern references:
Singleton pattern >Calendar classes.
Factory pattern > Wrapper class like Integer.valueOf.
Observer pattern > swing, awt.

Coupling: Coupling is the measure of the degree of interdependence between the modules. A good software will have low coupling.
Cohesion: Cohesion is a measure of the degree to which the elements of the module are functionally related.A good software will have high Cohesion.

 

 

DATABASES

Types of languages:
Data Definition Language (DDL) -> CREATE, ALTER, DROP, TRUNCATE, RENAME
Data Manipulation Language (DML) -> SELECT, UPDATE, INSERT, DELETE
DATA Control Language (DCL) -> GRANT and REVOKE
Transaction Control Language (TCL) -> COMMIT, ROLLBACK,SAVEPOINT

ACID
ATOMICITY: All or nothing rule.
CONSISTENCY: Database is consistent before and after the transaction.
ISOLATION: Transactions can be executed without leading to the inconsistency of the database state.
DURABILITY: Transactions commited in non-volatile memory to avoid system crashes.

Primary key vs Unique Key: Primary key can not be null, whereas unique key can be. Only one primary key per table, but multiple unique keys per table are allowed.
Normalization-is a process of analysing the given relation schemas according to their functional dependencies, more of splitting tables into smaller tables to reduce redundancy.
Denormalization -is a part of database optimization technique. This process is used to avoid the use of complex and costly joins, more of making bigger tables.
Delete vs truncate: Delete will delete partial rows based on condition, where as truncate will delete all rows from the table.
View – contains rows and columns from one or more table and can be defined as a virtual table.

SQL
Where vs Having : Having specifies a condition for a group or an aggregate function where as where clause selects before grouping or in simple terms,
where clause cannot be used with aggregates, but the having clause can.
Index: speed up performance of queries. It makes for faster retrieval of data from the table.
Triggers : A specific type of store procedure to perform a specific action on the table such as INSERT, UPDATE or DELETE.
Clustered vs NonClustered index:Clustered indexes reorders the physical order of the table and search based on the key values where
as nonclustered indexes do not alter the physical order of the table and maintain logical order of data.

HIBERNATE

Java Persistence API (JPA) provides specification for managing the relational data in applications.
Hibernate advantages:removes a lot of boiler-plate code that comes with JDBC API. It also supports inheritance, associations and collections.
SessionFactory- factory class reads configurations and connect to databases to get session object. It is threadsafe and immutable. Each application has only one SessionFactory instance and multiple threads can request session objects from this factory.
openSession vs getCurrentSession: getCurrentSession returns session current session whereas openSession always created a new session.
Get vs Load: get loads the data whenever it is called whereas load just returns proxy object and actually loads the data when required. Load supports lazy loading. We should use load data only when we know data exists.
save() vs saveOrUpdate():Save method saves a record only if it’s unique with respect to all integrity contraints otherwise fails, whereas saveOrUpdate will save if new record else update the existing record.
update() vs merge() : Update should be used in same session, whereas merge can be used in other session also.

Hibernate first level caching: Associated with session objects. Enabled by default and can not be disabled. There are methods availabled to clear session object/cache.
Hibernate Second level caching: Associated with session factory objects. Disabled by default and can not be enabled using third party jars, like ehcache.
Dirty checking : It helps to reduce database write times.Here it updates only those fields which require a change while others are not changed.

Hibernate entity bean states:
Transient: Newly created objects not yet associated with any session.
Persistent: Associated with session after calling get or load functions.
Detached: Previously persisited but now not assoiated with any session.

MONGO DB

MongoDB is a document-oriented database which stores BSON form data.
Namespace: Concatenation of the collection name and database name.
MongoDb does not support transaction management, like auto commit, rollback. They suggest to have schema designed in a way to minimize the need for multi document transactions.
However, MongoDB 4.0 added support for multi-document ACID transactions. One can try multi-document transactions against replica sets and until commites, no write operations are visible.
MongoDB vs Couch DB : MongoDb is recommended when there are dynamic queries and better performance while CouchDB is recommended if queries don’t change so frequently.
MongoDB doesn’t support ACID property and foreign key relationship.
Indexes are helpful for efficient scanning of documents/data in tables. By default, MongoDB has “_id” index for every collection.
Sharding is a method for storing data across multiple machines -horizontal partition of data.
Replication is the process of synchronizing data across multiple servers and it increases availibility and redundancy.
Syntaxes:
db.createCollection(name,options)
db.collection.drop()
db.collection.insert (document)

Microservices

Webservices disadvantage :Developers tries to make complex unmanageable and unnecessary interconnections between resources.

 

MQ

QueueManager is responsible for storing and routing messages to other Queue Manager
Dead letter Queue : Used by queue manager to route messages for non existing queues
binding connection vs client Connection: binding connection is used when mq client is in same physical server host, else we use client Connection
MQ message length : Max default :4MB, Can increase upto 100 MB

 

Spring

Spring Framework has layered architecture,one can use what he/she need and leave which is not required.

Dependency Injection: We don’t create objects in code, but describe how they should be created.We describe which services are needed by which components in the configuration file.

Dependency Injection Types:
Constructor Injection: No Partial injection, works well if many properties
Setter Injection: Partial injection, works well if few properties
Interface Injection :

Inversion of control vs Dependency Injection: IOC is the principle where the control flow of a program is inverted, so instead of programmer controlling the flow of a program,
the external sources (framework, services, other components) take control of it. DI is a type of IOC.
IOC is a much broader term that includes, but is not limited to, DI
IoC without using DI: Template pattern because the implementation can only be changed through sub-classing.

IOC containers :
BeanFactory : factory class having collection of beans.
ApplicationContext : build on top of BeanFactory, with some additional features.

Auto wiring Types:
By Name, By Type, Connstructor, AutoDetect, no.

Annotations:
@Component: This marks a java class as a bean.
@Controller: This marks a class as a Spring Web MVC controller.
@Service: This annotation is a specialization of the component annotation.
@RequestMapping : is used to map web requests to Spring Controller methods

 

 

JAVA

 

JDK:Java Development Kit : tool necessary to compile, document and package Java programs
JRE: Java runtime environment : runtime environment in which Java bytecode can be executed
JVM: Java virtual machine : specification that provides a run-time environment in which Java bytecode can be executed.

Java is not 100% Object-oriented since it has eight primitive data types such as boolean,char, int.
Java don’t have pointers because they are unsafe and increases the complexity of the program.
JIT ( Just-In-Time compiler ) Program that helps in converting the Java bytecode into instructions that are sent directly to the processor.

Arraylist vs Vector : Arraylist is not synchronized whereas Vector is. If an element is inserted into the ArrayList, it increases its Array size by 50% whereas vectors doubles its size.
Heap vs stack memory: stack memory is used only by one thread of execution and lives till end of thread execution ,whereas Heap memory is used by all the parts of the application and lives till application ends.

Private : Same class only.
Default : No access to different package.
Protected : All but no different package non subclass.
Public : All access.

 

React js

 

React JS – Front end javascript library that allows developers to build reusable UI components
Advantages: Increased application performance via the Virtual DOM model and reuse components across multiple projects

Conceptually, components are like JavaScript functions

State vs props : State describes a default data value in a React component that can change over time whereas props describe the way a React component is configured.
React events : Events are reactions that are caused by user actions, like clicks, mouse overs
JSX is an HTML-like syntax that help to write HTML style code in JavaScript for readability, like
React.createElement( ‘div’, {className: ‘cssclass’}, null)
Virtual DOM: Reactjs creates a virtual dom which is a copy of page’s actual dom, and then react compare with actual dom, and then make changes to the page.
React JS vs React Native: React js is for web pages/front end whereas React native is for mobile systems, like Android, IOS

Debugging tools:
Linters
Debuggers (React Developer Tools)

Redux is a library compatible with and complements to React by providing a stable way to track this data between components.

component lifecycle methods:
The componentDidMount() method runs after the component output has been rendered to the DOM.
componentWillUnmount() to teardown values.

Leave a Comment

Your email address will not be published. Required fields are marked *