Preguntas para Practicar Entrevistas
Preguntas para Practicar Entrevistas
public T getValue() {
return value;
}
1
}
}
class MiClase {
private String campoPrivado = "¡Este es un campo privado!";
What is an object?
● An object is a specific instance of a class. It represents a real-world entity and has associated attributes (data)
and methods (functions). An object is created by instantiating a class using the "new" keyword.
What is the difference between pass by value and pass by reference?
● In pass by value, a copy of the original parameter value is passed, while in pass by reference, the memory
address of the original value is passed.
What is a constructor?
● Is a special method within a class that is automatically called when creating an object of that class. It is used
to initialize the object's attributes.
What is constructor overloading?
● Constructor overloading involves having multiple constructors in a class, each with a different signature
(number or type of parameters). It allows for the creation of objects in various ways.
How do you handle exceptions in Java?
● Exceptions in Java are handled using the "try-catch" block. Code prone to errors is placed within the "try" block,
and exceptions are handled in the "catch" block.
2
● Lambda expressions are anonymous functions that don't require a class. Their structure is: (parameters) ->
{lambda body}. They work in conjunction with functional interfaces to assign different behaviors to an abstract
method.
Immutable objects
● It envolves careful design practices, such as declaring fields as final, avoiding setter methods, and ensuring that
the object's state is set only through the constructor or static factory methods.
ExecutorExample:
import java.util.concurrent.Executor;
3
public static void main(String[] args) {
// Creating an Executor (in this case, using a simple executor)
Executor executor = Runnable::run; // This runs tasks in the same thread.
ExecutorService Example:
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
Multithreading
Multithreading provides a way to achieve parallelism, and it's important to handle synchronization properly to avoid race
conditions and ensure thread safety.
// Synchronized methods
synchronized (objetoBloqueo) {
// Código que necesita sincronización
}
4
What is a Singleton?
● Is a design pattern that ensures that a class has only one instance and provides a way to access that instance
from any point in the application. Use cases: Database Connection Pooling, Logging, Configuration Management,
Caching.
public class Singleton {
// Instancia única
private static Singleton instancia;
Spring
What is Dependency Injection?
● Is the process of providing the dependencies that a class requires, rather than being created internally. The
Spring IoC container injects these dependencies into the object during its creation. Simplifies unit testing, as it is
easy to provide mock or test implementations of dependencies.
SQL
Diference between Stored procedures and functions:
● Stored procedures are more suitable for operations that directly affect the database, while functions are more
suitable for calculations and data manipulations that return a value.
5
JOINS
Web
What are the protocols for working with web services?
● SOAP (Simple Object Access Protocol) and REST (Representational State Transfer). These define how
communication should occur between applications on different systems.
List several ways you can communicate asynchronously with the server?
● AJAX, Fetch API, WebSockets, Server-Sent Events (SSE)
CSS
What are some of the ways to apply style to a web page?
● Inline Styles, Internal Styles (Embedded Styles) within the <style>, External Styles with CSS file using <link>,
CSS Selector Types, Media Queries, CSS frameworks.
JavaScript
What is destructuring in JavaScript?
● Destructuring is a feature that allows objects or arrays to be broken down into smaller parts to access their
elements more directly.
const person = { name: 'John', age: 30 };
6
const { name, age } = person;
console.log(name); // Output: John
// Using Object.assign()
const original = { a: 1, b: 2 };
const clone = Object.assign({}, original);
Angular Questions
Two way binding in Angular
● Is a mechanism that allows the data synchronization between the model (component) and the view (template).
It combines property binding and event binding into a single syntax using the ngModel directive.
Forms
● Angular provides two types of forms: Template-Driven Forms defined in the template using directives like
ngForm, ngModel, etc. Suitable for simple scenarios and quick development.
● and Reactive Forms (Model-Driven Forms). Defined programmatically in the component using FormBuilder
and FormControl. Suitable for complex scenarios and better control over form logic.
Form groups
● A form group is a collection of form controls that are part of a larger form. It allows you to organize controls
hierarchically and is commonly used in reactive forms.
Design Patterns
● Angular applications often use design patterns such as Singleton, Dependency Injection, and Observer (using
Observables) to enhance modularity, maintainability, and testability.
Observable Promise
● Represents a stream of values or events over time. ● Represents a single future value or error.
● Can be cancelled. ● Not cancellable.
● Supports multiple values over time. ● Supports a single value resolution.
7
● Lazy, only executes when subscribed to. ● Eager, executes immediately when created.
Subject Observable
● Represents a stream of values or events over time. ● Represents the idea of an invokable collection
● Can be cancelled. of future values or events.
● Supports multiple values over time. ● Lazy by nature.
● Lazy, only executes when subscribed to.
Communication between parent and child components in Angular can be achieved using Input properties for passing
data from parent to child, and using Output properties and EventEmitter for passing data from child to parent.
handleChildEvent(data: string) {
console.log('Data received from child:', data);
}
}
Example of Child Component:
// child.component.ts
selector: 'app-child',
template: '<p (click)="sendDataToParent()">Click me!</p>'
})
export class ChildComponent {
@Input() data: string;
@Output() childEvent = new EventEmitter<string>();
sendDataToParent() {
this.childEvent.emit('Data from child');
}
}
This allows for bidirectional communication between parent and child components in Angular.