OCA – Using Loop Constructs

What will the following code print when run? public class TestClass { public static void main(String[] args) throws Exception { String[] sa = {“a”, “b”, “c”}; for(String s : sa){ if(“b”.equals(s)) continue; System.out.println(s); if(“b”.equals(s)) break; System.out.println(s+” again”); } } } To determine the output you have to run through the loop one iteration at a … Leggi tutto

OCA – Java – methods

in Java, the order for initialization statements is as follows: PRIMA TUTTE LE COSE STATIC (sia fields che statements) NELL’ORDINE ESATTO IN CUI SONO INSERITI static variables and static initializers in order. instance variables and instance initializers in order. constructors. First, static statements/blocks are called IN THE ORDER they are defined. Next, instance initializer statements/blocks … Leggi tutto

Java Exception

The Role of Exceptions: An exception is Java’s way of saying, “I give up. I don’t know what to do right now. You deal with it.”     Notice that you’re using two different keywords here: throw tells Java that you want to throw an Exception. throws simply declares that the method might throw an … Leggi tutto

React + Redux Toolkit tutorial

Install Redux Toolkit and React-Redux   npm install @reduxjs/toolkit react-redux   Create a Redux Store   import { configureStore } from ‘@reduxjs/toolkit’ export const store = configureStore({ reducer: {}, })   Provide the Redux Store to React   import React from ‘react’ import ReactDOM from ‘react-dom’ import ‘./index.css’ import App from ‘./App’ import { store … Leggi tutto

OCM – Test example answer

Methods and Encapsulation: APPUNTI: Studia i metodi astratti e native Studia instanceOf studia gli operatori Encapsulation State e eredità https://docs.oracle.com/javase/tutorial/java/IandI/multipleinheritance.html Ereditarietà multipla di stato, implementazione e tipo Una differenza significativa tra classi e interfacce è che le classi possono avere campi mentre le interfacce no. Inoltre, puoi creare un’istanza di una classe per creare un oggetto, … Leggi tutto

Class Components vs Functional Components in React

Prima solo le class components possono avere lo State in un component. Ma ora con i React HOOKS i functional component è cambiato tutto le class component: import React, { Component } from ‘react’ class AppTest extends Component { render() { return ( Hello i’m class component ) } } export default AppTest Functional component: … Leggi tutto

This e Super() in Java

This this serve a disambiguare. Mettiamo il caso che creiamo un costruttore con i parametri, e passiamo i parametri con lo stesso nome degli attributi della classe che vogliamo inizializzare, this serve a dire a Java che ci riferiamo all’attributo e non al parametro in ingresso del costruttore. public class Persona(){ private String nome; private … Leggi tutto