
Java di base
Presentation
•
Computers
•
9th Grade
•
Medium
Michele Minno
Used 52+ times
FREE Resource
9 Slides • 15 Questions
1
Java di base
By Michele Minno
2
Variabili
'Scatole' in memoria di un certo tipo e nome
Per ospitare valori di quel tipo
es.: double piGreco = 3.14;
Some text here about the topic of discussion
3
Multiple Choice
Quale delle seguenti istruzioni NON è corretta?
int x = 9;
int x;
double x = 9;
double x;
4
Multiple Choice
Alla riga 10 ho la seguente istruzione nel codice:
String s;
Quale delle seguenti istruzioni è corretta se scritta dalla riga 11 in poi?
String s;
String s = "ok";
s = "ok";
Tutte e tre le altre risposte
5
Open Ended
Scrivi l'istruzione per dichiarare una variabile per i mesi dell'anno e inizializzala direttamente con il valore del primo mese dell'anno.
6
Scelta
Fai qualcosa se una condizione è vera, altrimenti fai qualcos'altro
if(condizione) { ... }
else if(altra condizione) { ... }
else() { ... }
Some text here about the topic of discussion
7
Multiple Choice
Cosa stampa su schermo?
n: 3
n: 2
n: 1
n: 0
8
Open Ended
if(i > 0) { System.out.println("ok"); }
...
Come continua il codice se voglio stampare "no" se i è minore di zero e "boh" se i è uguale a 0?
9
Loop
Ripeti finché una condizione è vera
while(condizione) { ... }
for(inizializzazione; condizione; incremento) { ... }
Some text here about the topic of discussion
10
Multiple Choice
Stampa i numeri 0, 2, 4, 6, 8, 10
for(int i = 0; i <= 10; i++) { System.out.println(i); }
for(int i = 0; i <= 10; i = i + 2) { System.out.println(i); }
for(int i = 0; i <= 10; i + 2) { System.out.println(i); }
for(int i = 0; i <= 10; i++) { System.out.println(i+2); }
11
Open Ended
Stampa i numeri 3, 2, 1, 0 (usando un loop)
12
Array
Liste ordinate di elementi
Array vuoto con 3 posti (ad es.): String[] parole = new parole[3];
Oppure già inizializzato con gli elementi:
String[] parole = {"ciao", "come", "va"};
parole[2] corrisponde a "va" (la terza parola, in posizione 2)
parole.length è uguale a 3 (la dimensione dell'array)
Some text here about the topic of discussion
13
Multiple Choice
Come faccio a stampare su schermo il 3° elemento di un array chiamato 'numeri'?
System.out.println(numeri[3]);
System.out.println(numeri[2]);
System.out.println(numeri{3});
System.out.println(numeri{2});
14
Open Ended
Come creo un array di 4 booleani di cui il primo e il quarto sono false ed il secondo ed il terzo sono true?
15
Scanner
Per leggere l'input dell'utente
Legge il valore che ha inserito l'utente prima di aver premuto 'Invio'
Lo impacchetta in valori di un certo tipo (es.: int, double, String, ..)
Utile per interagire con l'utente
Some text here about the topic of discussion
17
Open Ended
Come leggo il numero intero inserito dall'utente (ho già precedentemente creato l'oggetto 's' di tipo Scanner)?
18
Random
Per creare numeri casuali
Posso dare il limite estremo a cui tendere (ma non raggiungere)
ad es.: random.nextInt(10) mi dà un numero casuale da 0 a 9
Utile per tirare un dado, inizializzare un array con numeri a caso, ecc.
Some text here about the topic of discussion
19
Multiple Choice
Come posso generare un numero intero casuale tra 3 e 10?
random.nextInt(3, 10)
random.nextInt(10)
3 + random.nextInt(7)
3 + random.nextInt(8)
20
Open Ended
Come creo l'oggetto per generare i numeri casuali?
21
Operatori logici
Per creare condizioni booleane complesse
AND: &&
OR: ||
NOT: !
Ad. es.: if(trovato && !dispari) { ... }
Some text here about the topic of discussion
22
Operatori matematici e confronto
Per operazioni matematiche di base e confrontare due valori (esempi)
x = x * 4;
int r = x % 5;
if(x <= 10)
if(x != 3)
Some text here about the topic of discussion
23
Multiple Choice
int a = 10;
int b = 4;
if(a <= 10 && (b % 3 == 0 || b % 2 == 0)) { a--; }
else { a++; }
Quanto vale a dopo l'esecuzione del codice qui sopra?
10
9
11
Nessuna delle altre risposte
24
Open Ended
int i = 0;
int[] numeri = {10, 20, 30, 40, 50, 60, 70, 80, 90};
Qual è la condizione da mettere in un while che effettui massimo 5 iterazioni e che stampi su schermo in ogni iterazione un numero dell'array non multiplo di 4, scandendo gli elementi dell'array a partire dal primo?
Java di base
By Michele Minno
Show answer
Auto Play
Slide 1 / 24
SLIDE
Similar Resources on Wayground
18 questions
Spanish Present Tense Regular Verbs
Presentation
•
9th Grade
20 questions
fast food
Presentation
•
KG
18 questions
Algebra - Introduction to Functions
Presentation
•
9th Grade
18 questions
TIK - KELAS 9 - PERTEMUAN 1
Presentation
•
9th Grade
19 questions
QUARTER 4 WEEK 1 - INSTALLING AND CONFIGURING COMPUTER SYSTEMS
Presentation
•
9th Grade
17 questions
Parallel Structure
Presentation
•
9th Grade
19 questions
Parallel and Perpendicular Lines
Presentation
•
9th Grade
19 questions
Solving Equations with Variables on Both Sides
Presentation
•
9th Grade
Popular Resources on Wayground
10 questions
HCS SCI 03 Summer School Assessment 1
Quiz
•
3rd Grade
15 questions
HCS SCI 05 Summer School Assessment 1 Review
Quiz
•
5th Grade
22 questions
Day 9 Equations and Inequalities Review
Quiz
•
9th Grade
10 questions
Writing and Identifying Ratios Practice
Quiz
•
5th - 6th Grade
7 questions
PYRAMID PERSPECTIVES part 1
Presentation
•
9th - 12th Grade
12 questions
Understanding the Fourth of July
Quiz
•
9th Grade
15 questions
Soccer World Cup Quiz Questions
Quiz
•
7th Grade