wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Basic - 3 settimana corso dstech

Total questions: 93

Worksheet time: 2hrs 9mins

Name
Class
Date
1.

Quali delle seguenti affermazioni relative alle interfacce java è vera?

a)

una interfaccia può definire campi non statici

b)

i metodi di un'interfaccia hanno visibilità di accesso package

c)

i campi di una interfaccia sono final

d)

una interfaccia può estendere una classe astratta

2.

Nel linguaggio Java, a cosa servono i costruttori?

a)

Definire un metodo di un oggetto

b)

Definire il codice per l'implementazione delle interfacce

c)

definire le istruzioni da eseguire quando si istanzia un oggetto

d)

È un metodo particolare per invocare il super()

3.

cos'è il bytecode

a)

La quantità di memoria allocata dinamicamente

b)

La quantità di memoria allocata staticamente per le code di stampa

c)

Il contenuto di un file di estensione class

d)

il codice ASCII o UNICODE dei singoli Byte

4.

Una classe è...

a)

L'istanza di un oggetto

b)

L'insieme delle dichiarazioni degli oggetti

c)

Un modello astratto per una famiglia di oggetti con caratteristiche simili

d)

Il nome che rappresenta un oggetto

e)

Un programma contenente il metodo main()

5.

Un oggetto è

a)

colui che manda un messaggio

b)

una istanza di una classe

c)

un insieme di caratteristiche simili

d)

una classe non astratta

e)

un programma che rappresenta una classe

6.

Un array monodimensionale (o vettore) è...

a)

un insieme di valori ordinati

b)

un insieme di dati dello stesso tipo

c)

un insieme di dati individuabili tramite indice

d)

una serie di valori vuoti

e)

una serie ordinata di interi

7.
We are use For loop ..........
a)
To repeat a specified number of operations.
b)
To repeat a unspecified number of operations.
c)
All answers are correct
8.
When we want to print in Java, we use the code ......
a)
system.out.print();
b)
System.out.println();
c)
System.Out.Printf();
d)
System.out.show();
9.

Which data type gets returned from length() method in String class?

a)

double

b)

String

c)

int

d)

number

10.

What will be the output of below code?


String statement = "Outfit of the day";

System.out.println(statement.Substring(3,6));

a)

it of

b)

tfit

c)

fit

d)

FIT

11.

The following Syntax is used for?


class Subclass-name extends Superclass-name

{

//methods and fields

}

a)

Polymorphism

b)

Encapsulation

c)

Inheritance

d)

None of the above

12.

Class Cat extends Animal. Which is NOT a valid declaration?

a)

Cat x = new Cat();

b)

Animal X = new Animal();

c)

Cat x = new Animal();

d)

Animal x = new Cat();

13.

What index value is used to locate the last element in the nums ArrayList?

a)

nums.size()-1

b)

nums.length()-1

c)

nums.size()

d)

nums.length

14.

Which statement below is the correct way to retrieve the first element in the nums ArrayList?

a)

nums.get(0)

b)

nums[0]

c)

nums(0)

d)

nums[1]

15.

What will print when the following code executes?

ArrayList<Integer> list = new ArrayList<Integer>();

list.add(7);

list.add(8);

list.add(9);

System.out.println(list.remove(0));

a)

7

b)

8

c)

9

d)

0

16.

What is the keyword "final" used for in Java?

a)

identify a constant

b)

identify an integer

c)

identify a string

d)

Identify a final answer

17.
These controls the behavior of a program.
a)
class
b)
object
c)
method
d)
void
18.
What happens if a variable or method is made private?
a)
It can be accessed by any class inherited from the current class
b)
It can be accessed from another object unrelated to the current one.
c)
It cannot be accessed by an unrelated object from the outside.
d)
It cannot be accessed by anything
19.
What keyword is used to allow one class to inherit from another?
a)
extend
b)
extends
c)
extension
d)
exterminate
20.
Java is highly portable because 
a)
it creates a single executable file that works on all computers.
b)
it creates a single byte code file that is interpreted at the user's computer.
c)
everyone uses it.
d)
it says so in the text book.
21.

2

a)

5

b)

7

c)

9

d)

13

e)

20

22.
a)

-1 0 2 5

b)

-1 0 3 7

c)

-1 1 4 8

d)

0 2 5 9

e)

0 1 3 7

23.

Java method (function/module) definitions can contain which of the following parts in their headers?

a)

An access modifier such as public or private

b)

An optional access specifier called static

c)

a return type or void

d)

all of the above

24.
Which is the correct way to declare an ArrayList of Strings in Java?
a)
ArrayList<String>
b)
ArrayList(String)
c)
ArrayList[String]
d)
ArrayList{String}
25.

IronMan or Thor?

a)
b)
26.
_______ is how we write code
a)
Syntax
b)
Loops
c)
Variables
d)
Functions
27.
In the code example: hero.moveRight(), what is the object?
a)
move
b)
hero
c)
()
d)
Right
28.
what does CPU stand for??
a)
Central Processing unit
b)
Control Processing unit
29.
Which type of data is used to enter the value ("Welcome")?
a)
Text
b)
Characters
c)
String
d)
Boolean
30.
If a method of a class is defined like this:
goDown();
what does the () mean?
a)
It requires data to be passed in
b)
It has no parameters
c)
It can be called from BlueJ
31.
An object created from a class in a java program is known as an object...
a)
method
b)
instance
c)
parameter
32.
The arithmetic operator '==' is used to...
a)
Assign to variable
b)
Test to see if equal
c)
Create new variable
d)
add two variables together
33.
The arithmetic operator '=' is used to...
a)
Assign to variable
b)
Test to see if equal values
c)
create a new variable
d)
add two variables together
34.

Which of this command has errors? Select multiple

a)

System.out.print("Hello World")

b)

System.out.print(Hello World);

c)

System.out.Print("Hello World);

d)

System.out.print("Hello World");

35.

What is output by the code? Pretend it says System.out.println

a)

2

b)

3

c)

4

d)

5

e)

6

36.

What is ouptut by the code? Pretend it says System.out.println

a)

2

b)

3

c)

4

d)

5

e)

6

37.

What is output by the code?

a)

123

b)

12

c)

1234

d)

12345

e)

4321

38.
a)

123

b)

12

c)

1234

d)

12345

e)

4321

39.

Pretend it says System.out.println

a)

1383

b)

83

c)

1813

d)

181383

e)

1318

40.
a)

1 2 4 8 16 32 64

b)

1 2 4 8 16 32

c)

2 4 8 16 32 64

d)

2 4 8 16 32

e)

4 8 16 32 64

41.
a)

200 66 22 7 2

b)

66 22 7 2

c)

200 66 22 2

d)

200 66 22

e)

7

42.

2

a)

5

b)

7

c)

9

d)

13

e)

20

43.

How many times does the for loop run?

a)

2

b)

3

c)

4

d)

5

44.

Consider the following code segment:

Line 1: int a = 10;

Line 2: double b = 10.7;

Line 3: double c = a + b;

Line 4: int d = a + c;

Line 5: System.out.println(c + " " + d);


What will be output as a result of executing the code segment?

a)

20 20

b)

20.0 30

c)

20.7 31

d)

20.7 30.7

e)

Nothing will be printed because of a compile-time error.

45.

Consider the following code segment:

Line 1: int a = 10;

Line 2: double b = 10.7;

Line 3: int d = a + b;


Line 3 will not compile in the code segment above. With which of the following statements could we replace this line so that is compiles?


I. int d = (int) a + b;

II. int d = (int) (a + b);

III. int d = a + (int) b;

a)

I

b)

II

c)

III

d)

I and III

e)

II and III

46.
a)

0

b)

2.5

c)

6

d)

12.5

e)

60

47.

Assume that a, b, and c have been declared and initialized with int values. The expression


!(a > b || b <= c)


is equivalent to which of the following?

a)

a > b && b <= c

b)

a <= b || b > c

c)

a <= b && b > c

d)

a < b || b >= c

e)

a < b && b >= c

48.

Who invented Java?

a)

James Gosling

b)

Sergey Brin

c)

Steve Jobs

d)

Bill Gates

e)

Tim Berners-Lee

49.

What is the name of the Java mascot?

a)

Duke

b)

Ronny

c)

Penguin

d)

James

e)

Jack

50.

Which company owns Java?

a)

Oracle

b)

Microsoft

c)

Google

d)

Apple

e)

Intel

51.

If I say the word "Algorithm" I am talking about what?

a)

When we all go to a store called Rithim.

b)

Algae that can DANCE!!!

c)

A new dance move.

d)

A list of steps you follow to finish a task.

52.
What is coding?
a)
Something used to develop computer programs. 
b)
A form of "language" use to communicate computer actions. 
c)
An essential part to everything we do online. 
d)
All of these options are correct. 
53.

The variable "trash" will store what value?

a)

2

b)

10

c)

1

d)

3

54.

The expression will equate to what value?

a)

5

b)

false

c)

true

d)

6

55.

What does the Java code print?

a)

true

b)

2 = 2

c)

2

d)

false

56.

What will the code print?

a)

Jimmy

b)

Timmy

c)

Potatoes

d)

A blank line

57.

What value is printed to the console?

a)

true

b)

W

c)

false

d)

L

58.

What value is printed to the console?

a)

This restaurant is not my favourite.

b)

This restaurant is good.

c)

This restaurant is fantastic!

d)

I've never dined at this restaurant.

e)

3

59.
Debugging is...
a)
Stepping on a bug .
b)
Finding and fixing errors in programs.
c)
Turning off  your computer.
d)
Relaxing.
60.
Function is..
a)
A math equation.
b)
A piece of code that you can easily call over and over again.
c)
Finding an error in a program.
d)
Is short for fun vacation.
61.
Given the following method, what would test return if
a = {0, 2, 3, 4} and v = 1?
a)
-1
b)
0
c)
1
d)
2
62.
Given the following method, what would test return if
a = {0, 2, 3, 4} and v = 2?
a)
0
b)
1
c)
2
d)
-1
63.

Given the nums ArrayList with the values [1, 2, 3, 4, 6], what code below can be used to add a 5 between the 4 and 6 in the list?

a)

nums.add(4, 5)

b)

nums.add(5, 4)

c)

nums.add(5, 5)

d)

nums.add(5)

64.

What is printed as a result of executing the following code?

ArrayList<Integer> alist = new ArrayList<Integer>();

alist.add(1);

alist.add(2);

alist.remove(1);

alist.add(1, 3);

alist.set(1, 4);

alist.add(5);

System.out.println(alist);

a)

[1, 4, 5]

b)

[1, 4, 3, 5]

c)

[2, 4, 5]

d)

[2, 4, 3, 5]

65.
Which of these cannot be passed down through inheritance?
a)
Public variables
b)
Private variables
c)
Methods
d)
Data
66.

What is their favourite food

a)

Ice-cream

b)

Tacos

c)

Sushi

d)

Pizza

67.

What is your favourite

a)

DC Comics

b)

Marvel

68.
How many regions does Italy have?
a)
21
b)
27
c)
15
d)
20
69.
Keyboard is ......... device?
a)
An Output
b)
An Input
c)
Software
d)
Memory
70.
Monitor is ........ device?
a)
An Input
b)
An Output
c)
CPU
d)
Both 1 & 2
71.

Steps

a)

Input ---> Process ---> Output

b)

Input ---> Output ---> Process

c)

Output ---> Process ---> Input

72.
Who said,
“Only your hatred can destroy me.”
a)
Emperor Palpatine
b)
Darth Vader
c)
Darth Maul
d)
Count Dooku
73.
On what planet does Jabba the Hutt live?
a)
Bespin
b)
Coruscant
c)
Tattooine
d)
Alderaan
74.
Who was Obi-Wan Kenobi's Master?
a)
Darth Maul
b)
Qui-Gon Jinn
c)
Darth Sidious
d)
Yoda
75.

Plato was a student to which philosopher?

a)

Aristotle

b)

Xenophon

c)

Socrates

d)

Thomas Aquinas

76.

Cosa definisco quando implemento l'interfaccia comparable

a)

un ordinamento al momento

b)

un ordinamento naturale

c)

la possibilità di salvare su file

d)

la possibilità di usare una lista

77.

L'interfaccia ________ serve a darci la possibilità di salvare su stream oggetti da noi costruiti

a)

Comparable

b)

Saverizable

c)

Serializable

d)

Corruptable

78.

Possiamo gestire una eccezione con il solo Try, senza blocco catch?

a)

Si, ma dobbiamo fare il throws

b)

Si, ma dobbiamo fare il new throw

c)

No, dobbiamo per forza mettere il catch

d)

Si, a patto che chi richiami il metodo metta il catch

79.

Cos'è una IndexOutOfBoundException

a)

Una eccezione generata da un accesso ad un oggetto non inizializzato

b)

Una eccezione generata da un blocco try catch scritto male

c)

Una eccezione generata da un accesso inconsistente su un collezione

d)

Una eccezione generata da un errore in compilazione

80.

Cosa è una NullPointerException

a)

Una eccezione generata da un oggetto inconsistente

b)

Una eccezione generata da un file inesistente

c)

Una eccezione generata da un pezzo di codice che accede al db danneggiato

d)

Una eccezione generata da un tipo di base =0

81.
MySQL is
a)
A Programming language
b)
A technique for writing reliable programs
c)
 A Relational Database Management System
d)
None of the Above
82.
What does "Select" command do at MySQL database? 
a)
Write.
b)
Read.
c)
Delete.
d)
Update.
83.
What is this code do ?
a)
Read all from staff table.
b)
Write from staff table.
c)
Update all from table.
d)
Drop table.
84.
A database entity is also known as:
a)
a table
b)
a field
c)
a row
d)
a report
85.

If you were wanting to filter data, which clause would you use?

a)

Where

b)

Order by

c)

From

d)

Select

86.

What is the correct order of clauses in a SQL statement?

a)

SELECT, FROM, ORDER BY, WHERE

b)

SELECT, FROM, WHERE, ORDER BY

c)

SELECT, WHERE, FROM, ORDER BY

d)

WHERE, FROM, SELECT, ORDER BY

87.

Which example of the field name below is in camel case?

a)

First Name

b)

firstName

c)

FIRSTNAME

d)

firstname

88.
When you select data from 2 tables, you are creating a ________. 
a)
JOIN
b)
PRIMARY KEY
c)
FOREIGN KEY
d)
INDEX
89.
To join a table, connect the ___________ of one table to the ___________ of the other.
a)
primary key, foreign key
b)
group by clause, primary key
c)
filtered by, foreign key
d)
aggregate function, where clause
90.

Which of the queries is most likely to have produced this result?

a)

ANSWER: SELECT id, name, year FROM movies WHERE year > 2010;

b)

ANSWER: SELECT id, name, year FROM movies WHERE year < 2010;

c)

ANSWER: SELECT * FROM movies WHERE year > 2010;

d)

ANSWER: SELECT id, name, year FROM movies WHERE YEAR > 2010;

91.
What should a primary key contain?
a)
A lot of different values
b)
A null value
c)
An unique value
92.
What happens if you forget to join two tables together  using a WHERE clause?
a)
CREATE CARTESIAN PRODUCT
b)
GET A SYNTAX ERROR
c)
0 RECORDS RETURNED
d)
DELETE ALL
93.
Who teaches Mowgli the bare necessities of life?
a)
Baloo
b)
Abu
c)
Lucifer
d)
Diablo