Problem bei OCA Übungsfragen

Mike82

Mitglied
Hallo,

ich lerne gerade über einen Weiterbildungskurs für eine OCA Prüfung.

Bei 3 meiner Übungsfragen habe ich das Problem, dass angeblich mehrere Antworten korrekt sein sollten, bin mir aber bei nur einer jeweils relativ sicher.

Könnt ihr mir da bitte weiterhelfen?

1. Frage:
Which two items can legally be contained within a java class declaration?

A) An import statement
B) A field declaration
C) A package declaration
D) A method declaration

Ich habe jetzt gedacht, nur die method declaration wäre richtig. Welches ist dann das zweite?

2. Frage:
Which two actions will improve the encapsulation of a class?

A) Changing the access modifier of a field from public to private
B) Removing the public modifier from a class declaration
C) Changing the return type of a method to void
D) Returning a copy of the contents of an array of ArrayList instead of a direct reference

Ich würde A meinen, und als zweites C.

3. Frage
Which two statements are true for a two-dimensional array of primitive data type?

A) It can't contain elements of different types
B) The lengh of each dimension must be the same
C) At the declaration time, the number of elements of the array in each dimension must be specified
D) All methods of the class object may be invoked on the two-dimensional array

Hier glaube ich C wäre richtig. Als weitere Antwort denke ich A.

Viele Liebe Grüße,
Mike
 

Mike82

Mitglied
Vielen Dank, Flown!

Kannst Du mir bei folgender auch nochmal bitte helfen?

Which two demonstrate the valid usage of the keyword synchronized?

A)
interface ThreadSafe {
synchronized void dolt();
}

B)
abstract class ThreadSafe {
synchronized abstract void dolt();
}

C)
class ThreadSafe {
synchronized static void solt() {}
}

D)
enum ThreadSafe {
one, two three;
synchronized final void dolt () {}
}


Ich hätte nur C) gesagt. Es sollen aber 2 richtig sein.
 

CptSocket

Aktives Mitglied
Hallo Mike

C und D:

synchronized kannst du immer dann angeben, wenn eine Methode nicht nur deklariert, sondern auch implementiert wird.
(Unabhängig davon, ob die Methode in einer abstrakten Klasse definiert, oder ob sie als static oder final gekennzeichnet ist. Ob eine synchronized Methode in einem enum Sinn macht oder nicht ist eine andere Frage ...)


Freundliche Grüsse
CptSocket
 

Neue Themen


Oben