Hi There! So I have drafted some Java, and RESTAPI questions I was asked on an interview and their answers. Sources are also included. How do you read a file in java? Step1: Use java io.file library, Files and Path classes. Step 2: make sure your method throws IO Exception. Step 3: Make a byte …
Author Archives: roynunez
How to read a file in Java
Hi there! Welcome back! Today I will talk about the different ways to read a file in Java. For starters there are two classes you can use to read and write files in Java. There are Java I/O classes and Java NIO Streams. The main difference between these two packages is that the read() and write() methods of Java …
Design Patterns
A design patterns are patterns that explain, motivate and names a general design in the problem solving process in object-oriented programming. https://www.geeksforgeeks.org/software-design-patterns/ There are different classification systems that design patterns fall under creational, behavior and structural . Creational design patterns abstract the instantiation process. They increase independecy of the creation, composition and representation of the …
DOM and SAX
Hey all! Welcome back! In this blog I will be briefly going over some XML parsers like DOM and SAX and in another blog delve in deeper into JAXB. To name some of the differences between them is that DOM and Sax are lower-level APIs used to parse XML documents and JAXB is a higher-level …
JAXB
JAXB stands for Java Architecture for XML Binding. It is one of the simpler tools used to create and parse through XML documents. Specifically, it parses XML documents into Java objects but can convert Java objects into XML documents. In many cases JAXB takes less code and is easier to use. It Annotates java classes …
Structural Designs
Decorator Design Pattern Decorator is a structural design pattern that lets you attach new behaviors to objects by placing these objects inside special wrapper objects that contain the behaviors. In the UML diagram below you can see the VisualComponent abstract class for visual objects that defines their drawing and event handling interface. It Implements the TextView …
Creational Design Pattern
Factory Method lets a class defer instantiation to subclasses and we create objects without exposing the creation logic to client and the client use the same common interface to create new type of object. The creator class declares the factory method that must return an object of a product class. The creator’s subclasses usually provide …
Behavior Design Patterns
Strategy Design Pattern: In the strategy design pattern you are defining classes that encapsulate different linebreaking algorithms. Using this strategy you can make algorithms interchangeable and vary independently from the clients who use it. This software design pattern also enables an algorithm’s behavior to be selected at runtime. The Strategy pattern suggests that you take a class …
Injection in SQL
Hi all and welcome back! Today I will go over injection. SQL injection is a code injection technique, used to attack data-driven applications, in which malicious SQLstatements are inserted into an entry field for execution and can destroy your database. Scary huh. So this is why I am going to talk about it in this blog so you can avoid this …
Deep Cloning
Hi all and welcome back! On this blog I will be talking about deep cloning. Cloning is a process of creating an exact copy of an existing object in the memory. In java, clone() method of java.lang.Object class is used for cloning process. Not every object is able to undergo the cloning process. The objects which implement Cloneable interface are the only …