fdsa


J. F.
Diese Karteikarten bieten einen umfassenden Überblick über die Java-Programmierung, insbesondere zu Themen wie Dateiverarbeitung, Funktionen und Sammlungen. Sie decken wichtige Konzepte wie das Arbeiten mit Pfaden, Dateien und Strings ab, sowie das Verhalten von Sammlungen und deren Sortiermethoden. Die Karteikarten sind ideal für Entwickler, die ihr Wissen in Java vertiefen möchten, insbesondere in Bezug auf die Handhabung von Sammlungen, das Sortieren und Vergleichen von Objekten sowie die Verwendung von Stream-APIs und Collectors.
Karten
496
Lernende
3
Sprache
Deutsch
Kategorie
Informatik
Stufe
Andere
Erstellt / Aktualisiert
06.12.2020 / 24.01.2021

Lernkarten

What modifiers are required for serialPersistentFields?

private static final

How to ensure that fields are enrcrypted during serialization?

implementing writeObject(ObjectOutputStream s) and readObject(ObjectInputStream s)  and doing the encrpytion here

What exceotion is thrown when a field is marked with transient/is not in serialPersistentFields?

IllegalArguemntException

What is readResolve for?

When we want to control f.e. if a new object is created during deserialization

When does readResolve run?

After the readObject - method

What is writeReplace for?

F.e. if we want to conrtrol which object is serialized instead of just serializing this

When is writeReplace running?

before writeObject

How to construct sensitive objects?

  • Making class private
  • making method private
  • constructor private

What is a resource leak and how to prevent this?

When the resource is never closed -> close it

Why is reading of files w.o. cheging its size a problem?

The files could be very large -> check the size first to prevent memory issues

What is a inclusion attack?

F.e. billion laughs attack or zip bomb. A file which could expand more and more to become really big

What is the problem with ovwerflowing numbers? How to prevent?

Unpredictable outcomes -> input validation

What is "wasting data structures"?

F.e. the possibility to create a class with a hashCode which always return 42 and put it to a hashmap or the possibility to create very large datastructures

Does ArrayList have a copy method?

no

What does ArrayList.clone() return?

Object -> be aware to cast it

Where is the clone() Method declared?

In the objectclass

Whats the difference between a black and a whitelist?

Whitelist compares against allowed values (could also throw an exception if not valid)

What does readObject() return?

Object

What does readResolve() return?

Object

Where are the 5 key interfaces for JDBC declared?

In the JDK

Where do we get the concrete classes for JDBC interfaces from?

From the JDBC driver

Which interfaces are implemented within the driver JAR?

Driver, Connection, PreparedStatement, CallableStatement, ResultSet

Do we use the concrete JDBC classes in code?

No, only the interfaces

Whats neccessary in a jdbc url? Which colons?

prefix jdbc + subprotocol for the db + name/address of the database, separated by :

jdbc:postgresql://localhost/zoo

Is it possible to create a jdbc-connection via constructor

No, use DataManager.getConnection for the exam, in real life: DataSource

Which exception is thrown by DriverManager.getConnection?

SqlException  (check in examquestions if it is thrown)

What are the benefits of a PreparedStatement?

  • Performance
  • Security
  • Readability
  • Future use

Is it possible to create a preparedStatement without providing a query as parameter?

No, this will not compile:

var ps = conn.prepareStatement()

How to get the returned Value of ps.execute() ? 

Check first if it returned something (returned value will be boolean indicating if returnvalue or updatecount), then get the resultset via ps.getResultset if it is true or ps.getUpdateCount if it is false

What happens with incompatible returntypes? (f.e. SELECT-query but executeUpdate() called)

Will throw a SQLException like: .executeUpdate cannot be called with a statement

What is the returntype and the returnvalues for select/[delete|insert|update] for ps.execute()

boolean, true for select, false for updates

What is the returntype and the returnvalues for select/[delete|insert|update] for ps.executeQuery()?

ResultSet, rows and columns returned for select

What is the returntype and the returnvalues for select/[delete|insert|update] for ps.executeUpdate?

int, number of rows added/changed/removed returned for updates

Where does the bindvariables within a preparedStatement start to count? 

start with 1

What happens if not all bindVariables are set in a preparedStatement?

Code compiles but SQLException

What happens if to many bindVariables are provided for a prepared statement?

SQLException like "the number of values assigned is not the same as the number of specified or implied columns"

Can we use the same perparedStatement for multiple executeUpdates? Whats with the bindVariables?

Yes, the perparedStatement will remember the parameters that were already set if not changed

What does resultSet.next() do? 

Sets the cursor to the next element, returns boolean indicating if it worked

Where does the counting stat within a resultSet?

at 1

What params does f.e. resultSet.getInt accept?

either 1/2/.. or the columnname

Lernen