ocp 2


Kartei Details

Karten 141
Sprache Deutsch
Kategorie Informatik
Stufe Andere
Erstellt / Aktualisiert 22.09.2020 / 06.12.2020
Weblink
https://card2brain.ch/box/20200922_java_2_2
Einbinden
<iframe src="https://card2brain.ch/box/20200922_java_2_2/embed" width="780" height="150" scrolling="no" frameborder="0"></iframe>

Was gibt es für ResultSet-reading-modes für den ersten parameter von conn.createStatement( dieser hier, ResultSet.CONCUR_READ_ONLY)?

* TYPE_FORWARD_ONLY

* TYPE_SCROLL_INSENSITIVE  -> wenn daten such öndern bekommt man es nicht mit

* TYPE_SCROLL_SENSITIVE  -> wenn sich die daten ändern bekommt man es mit, not well supported

Was gibt es für ResultSetConcurrency modes für conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, dieserParameter)?

* CONCUR_READ_ONLY

* CONCUR_UPDATABLE  (resultset ist veränderbar)

Was passiert bei bvielen Datenbanken wenn man den ResultSettype ResultSet.CONCUR_UPDATABLE verwendet?

Man wird "downgegraded" zu CONCUR_READ_ONLY

Wie führt man sql insert/update/delete auf einem Statement aus? Was ist der returnwert?

stmt.executeUpdate("sqlstatement")
rückgabe ist anzahl rows die verändert wurden

Wie führt man auf einem Statement ein Select aus?

stmt.executeQuery("selectquery")

Was macht stmt.execute(sqlQuery)?

Führt eine sqlquery aus, egal ob update oder select. returned booleanwert ob resultset. Wenn resultset: stmt.getResultSet(), wenn nicht:stmt.getUpdateCount()

Was passiert wenn man bswp. executeUpdate für ein select-statement verwendet?

SQLException mit bspw. "A result was returned when none was expected"

Wie kann man dzurch ein resultset iterieren?

while(rs.next()) {

  rs.getInt("id"); rs.getString("name");

}

Was erlaubt einem ein scrollable ResultSet zu tun?

Den Cursor in jede Zeile zu platzieren

Was macht resultSet.first()?

Setzt den Curosor in die erste Reihe

Was macht resultSet.beforeFirst()?

Setzt den Cursor vor die erste Reihe

Was macht resultSet.last()?

Setzt den Cursor in die letzte Reihe

Was macht ResultSet.afterLast()?

Setzt den Cursor nach der letzten Reihe

Was ist der returnwert von resultSet.beforeFirst und afterLast?

void

Wie kann man den cursor in einem resultSet eine reihe zurücksetzen?

.previous()

Wie kann man den cursor in einenm Resultset x-stellen vor/rückwärts bewegen?

relative(int rowNum)

Was passiert mit einem Resultset wenn ein anderes SQL statement auf dem gleichen Statement laufengelassen wird?

Es wird geschlossen, auch ohne es explizit zu schließen

What is the purpose of an annotation?

To assign metadata attributes to classes, methods, variables and other Java tyoes

Where can annotations be applied?

any declaration including classes, methods, expressions, even other annotations

How to declare an annotation?

with @interface ,f.e.:
public @interface Exercise {}

How to add a required element to an annotation?

without default:
public @interface Exercicse {
  int hoursPerDay();
}

How to provide a optional element in an annotation?

with default:
public @interface Exercice {
  int hoursPerDay();
  int startHour() default 6;
}

Can we add null as a default value for an annotation?

No, must be nun null and constant

Which types can be used as ElementType within annotations?

primitive type, a string, a class, an enum, another annotation or an array of any of these types

Whats wrong here?
public @interface Panda {
  Integer height();
  String[][] generalInfo();
  Size size() default Size.SMALL;
  Bear friendlyBear();
  Exercies exercise() default @Exercise(hoursPerDay=2);
}

height - not a primitive
generalInfo: String[][] not supported, String[] would work
friendlyBear: Type is Bear, not class

What are Annotation-elements implicitely?

abstract and public

Whats wrong here?
public @interface Material {}
public @interface Fluffy {
  int cuteness();
  public abstract int softness() default 11;
  protected Material material();
  private String fiendly();
  final boolean isBunny();
}

matierial/friendly: accessmodifier conflicts with beeing public
isBonne: like abstractmethods cannot be marked final

Can we access annotation-values w.o. actually creating the annotation?

Yes

How can a annotation specify which declaration type it can be applied to?

With the @Target annotation

What are the rules a annotations has to adhere to be used with value but w.o. name?

  • annotaion declaration must contain an element named value() which may be optional or required
  • annotation declaration must not contain any other elements that are required
  • annotation usage must not provide values for any other elements

When can the shorthand notation for properties an array contains within an annotathin be used? How does it look like?

If it is only one value in the array:
@Music(genres="Classical") String something;

Does the notation shorthand for annotations also work for lists or collections?

no

How to use the @Target annotation?

Takes an array of ElementType enum values as its value() element

What are examples of ElementType values for @Target?

TYPE, FIELD, MODULE, TYPE_USE, TYPE_PARAMETER, PACKAGE, ANNOTATION_TYPE, LOCAL_VARIABLE, CONSTRUCTOR, PARAMETER, METHOD

What can be done with the @Retention annotion?

annotations may be can be discarded by the compiler or at runtime, depending of the value set as value() in the annotatin

What are possible values for @Retention?

SOURCE - used only in the soruce file, discared by the compiler
CLASS - stored in the .class file but not available at runtime
RUNTIME - stored in the .class file and available at runtime

How to include annotation information defined on javatypes in the javadocs?

@Documented

How to inherit annotation information from the parrent class?

with @Inherited

When is the @Repetable used?

when you want to specify an annotation more than once a type

Can a annotation be applied multiple times?

without the @Repetable annotation only once