You are on page 1of 6

Pros/advantages of Java

multiplataforma Performance (memory-consuming)


programacion OO Look and feel
gestrion de errores Memory management
librerias estandar

OOP (what is it, 4 main properties of that)


Encapsulamient Polymorphism gives us a way to use a class exactly like its parent so
o there is no confusion with mixing types
Abstraccion Abstraction is an extension of encapsulation. It is the process of selecting
data from a larger pool to show only the relevant details to the object
Herencia  Inheritance is the ability of one object to acquire some/all properties of
another object.
Polimorfismo Polymorphism gives us a way to use a class exactly like its parent so there
is no confusion with mixing types

What's a variable?
A Java variable is a piece of memory that can contain a data value

What's an array?
An array is a container object that holds a fixed number of values of a single type.

What's a class?
 A class is the blueprint from which individual objects are created.
What's an interface?
In general, an interface is a device or a system that unrelated entities use to
interact. Within the Java programming language, an interface is a type, just as a
class is a type.
What's a void method?
The void keyword allows us to create methods which do not return a value.
What's polymorphism?
the ability of a message to be displayed in more than one form.
What's inheritance?
It is the mechanism in java by which one class is allowed to inherit the
features(fields and methods) of another class. 
What's encapsulation?
Encapsulation is defined as the wrapping up of data under a single unit. It is the
mechanism that binds together code and the data it manipulates.
What's abstraction?
Data Abstraction is the property by virtue of which only the essential details are
displayed to the user. The trivial or the non-essentials units are not displayed to
the user
Overriding in Java
Overriding is a feature that allows a subclass or child class to provide a specific
implementation of a method that is already provided by one of its super-classes
or parent classes
Overloading in Java
Allows different methods to have the same name, but different signatures where
the signature can differ by the number of input parameters or type of input
parameters or both.
Difference between an array and arraylist

Basis Array ArrayList

Definition An array is a dynamically-created object. The ArrayList is a class of


It serves as a container that holds the Java Collections framework. It contains
constant number of values of the same popular classes like Vector, HashTable,
type. It has a contiguous memory and HashMap.
location.
Static/ Dynamic Array is static in size. ArrayList is dynamic in size.
Resizable An array is a fixed-length data structure. ArrayList is a variable-length data
structure. It can be resized itself when
needed.
Initialization It is mandatory to provide the size of an We can create an instance of ArrayList
array while initializing it directly or without specifying its size. Java creates
indirectly. ArrayList of default size.
Performance It performs fast in comparison to ArrayList is internally backed by the array
ArrayList because of fixed size. in Java. The resize operation in ArrayList
slows down the performance.
Primitive/ Generic An array can store We cannot store primitive type in
type both objects and primitives type. ArrayList. It automatically converts
primitive type to object.
Iterating Values We use for loop or for each loop to We use an iterator to iterate over
iterate over an array. ArrayList.

Type-Safety We cannot use generics along with array ArrayList allows us to store
because it is not a convertible type of only generic/ type, that's why it is type-
array. safe.
Length Array provides a length variable which ArrayList provides the size() method to
denotes the length of an array. determine the size of ArrayList.

Adding Elements We can add elements in an array by Java provides the add() method to add
using the assignment operator. elements in the ArrayList.

Single/ Multi- Array can be multi-dimensional. ArrayList is always single-dimensional.


Dimensional

¿Qué es una excepción?


An exception is an “unwanted or unexpected event”, which occurs during the
execution of the program
Tray Catch Throw throws finaly
The try block Catch block is Throw keyword Throws keyword  It is executed
contains set of used to handle is used to is used for after catch
statements the uncertain transfer control exception block. We
where an condition of try from try block to handling without basically use it
exception can block. A try catch block try & catch to put some
occur block is always block. It common code
followed by a specifies the when there are
catch block, exceptions that multiple catch
which handles a method can blocks.
the exception throw to the
that occurs in caller and does
associated try not handle itself.
block.

Java provides three types of control flow statements.


Decision Making statements
o if statements
o switch statement

Loop statements
o do while loop
o while loop
o for loop
o for-each loop

Jump statements
o break statement
o continue statement

Difference between for, while and do/while


Foor loop While loop Do-while loop
Is used to iterate a parto f the Is used to interate a parto f Is used to iterate a parto f the
program several times the program several times, if program several times, use it
the number of iterations is if the number of iteratios is
not fixed not fixed and you must have
to execute the loop at least
once

What's a constructor?
A constructor is a special method of a class or structure in object-oriented programming
that initializes a newly created object of that type. Whenever an object is created, the
constructor is called automatically

Difference between stack y heap


STACK HEAP
Almacena Variables locales Objetos (clases, métodos,
instancias)
Nunca se puede manipular Se puede redimensionar y
directamente tiene el ‘Garbage
Collector’
Tiene acceso al procesador, no
‘stack pointer’
La memoria no necesita ser Idem
contigua
Cada hilo tiene un stack Común a toda la JVM
OutOfMemory No tiene espacio para un Necesita más tamaño.
nuevo hilo.
StackOverflow Requiere más espacio del
permitido

Difference between string buffer and string builder


StringBuffer StringBuilder
Is synchronized Is not synchronized
Is thread-safe Is not thread-safe
Is slow Performance si better tan stringbuffer

Types of exceptions
Built-in Exceptions User-Defined exceptions
ArithmeticException
ArrayIndexOutOfBoundsException
ClassnotfoundExceptions

What's a hashmap?
Is a part of Java’s collection. It provides the basic implementation of the Map
interface of Java. It stores the data in (Key, Value) pairs, and you can access
them by an index of another type 
How are getters and setters used for?
Retrieving and updating the value of a variable outside the encapsulating class
Enum
An enum type is a special data type that enables for a variable to be a set of
predefined constants
What's an access modifier?

There are four types of Java access modifiers:

1. Private: The access level of a private modifier is only within the class. It
cannot be accessed from outside the class.
2. Default: The access level of a default modifier is only within the package. It
cannot be accessed from outside the package. If you do not specify any
access level, it will be the default.
3. Protected: The access level of a protected modifier is within the package
and outside the package through child class. If you do not make the child
class, it cannot be accessed from outside the package.
4. Public: The access level of a public modifier is everywhere. It can be
accessed from within the class, outside the class, within the package and
outside the package.

What's a thread?
Is the path followed when executing a program.

You might also like