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.
Flashcards
496
Students
3
Language
German
Category
Computer Science
Level
Other
Created / Updated
06.12.2020 / 24.01.2021

Flashcards

Is the call to serviceloader fast?

No

What is a service provider?

Implementation of a service provider interface

What do we have to add to the module-info.java when we are implementing a service provider?

provides interfaceName with className;

Do we have to recompile the service interface,. .. if we add a nw service provider implementation?

no, the service locator is able to observe that there was now a service provider implementation available and find it for us

How many service providers are allowed for a service provider interface within a module?

only one provuiider of a provider interface in a module

What is the signature of the two methods in serviceloader we have to know?

  • public static <S> ServiceLoader<S> load(Class<S> service) 
  • public Stream<Provider<S>> stream()

What does a traditionally try statement have at least?

try statement and at least a catch or a finally block

In which order are the resources cloused with try-with-resources?

In the reverse order that they are declared

What are the 5 checked exceptions we have to be familiar with?

FileNotFoundException, IOException, NotSerialziableException, ParseException, SQLException

From what Exception inherits NumberFormatException?

IllegalArgumentException

From what Exception inherits FileNotFoundException and NotSerializableException?

IOException

Does close in AutoClosable have to throw an exception?

the implemented version of close() can chose to throw an exception or a subclass or not throw any exceptions at all

In which scope are resources which are declared within a try-with-resources block?

in the scope within the try block

When is it possible to declare resources which are used within try-with-resoruces?

Also prior to the try-with-resorucres-statement if they are marked final or are effectively final

Where are supresses exceptions added?

Only to exceptions thrown in the try clause

Whats the syntax of assert?

assert test_value;

assert test_value: message;

--> may include optional parantheses and a message:

assert ("Bla".equals(bla)): "Failed";

What are the 4 important time classes for the exam?

  • java.time.LocalDate
  • java.time.LocalTime
  • java.time.LocalDateTime
  • java.time.ZonedDateTime

Can we call new LocalDate()?

No

Does this work?: 
LocalDate date = LocalDate.of(2020, Month.OCTOBER, 20);
LocalTime time = LocalTime.of(11,12,34);
System.out.println(date.format(DateTimeFormatter.ISO_LOCAL_TIME));
System.out.println(time.format(DateTimeFormatter.ISO_LOCAL_DATE));

No, will throw an exception because of incompatible types

How to add custom text values to dateTimeFormatters?

excape the text by surrounding it with a pair of single quotes: '
DateTimeFormatter.ofPattern("MMM dd', Party''s at' hh:mm);

How to get the users current locale?

Locale.getDefault()

How to get the german language from locale?

Locale.GERMAN

How to get the german region from Locale?

Locale.GERMANY

How to use the locale-builder?

new Locale.Builder().setRegion("US").setLanguage("en").build();

How to set the default locale?

Locale.setDefault(locale)

Does Locale.setDefault change the locale for the system?

No only for that one javaprogramm

What is the NumberFormat-method for getting a general-purpose formatter?

NumberFormat.getInstance()
NumberFormat.getInstance(locale)

What is the NumberFormat-method for getting a general-purpose formatter (with number instance)

NumberFormat.getNumberInstance()
NumberFormat.getNumberInstance(locale)

What is the NumberFormat-method for getting a formatter for formatting monetary amounts?

NumberFormat.getCurrencyInstance()
NumberFormat.getCurrencyInstance(locale)

What are the decimal format symbols?

# - omits the position if no digit exists for it   . $2.2
0 - put a 0 in the position if no digit exists for it  -  $002.20

How to custom format numbers?

new DecimalFormat("###,###,###.0");

How to get a DateTimeFormatter-instance for formatting dates=

DateTimeFormatter.ofLocalizedDate(dateStyle)

How to get a DateTimeFormatter-instance for formatting times?

DateTimeFormatter.ofLocalizedTime(timestyle)

How to get a DateTimeFormatter-instance for formatting dates and times?

DateTimeFormatter.ofLocalizedDateTime(dateStyle, timeStyle)
DateTimeFormatter.ofLocalizedDateTime(dateTimeStyle)

What are possible FormatStyle-parameters?

SHORT, MEDIUM, LONG, FULL

How to get a formatter for a specific locale?

Datetimeformatter.withLocale(locale)

How to set the default locale only for displaying data about the locale?

with Locale.Category value DISPLAY

How to set the default locale only for formatting dates,numbers or currencies?

With Locale.Category value FORMAT

Where is the resourcebundle stored?

in a properties file

What is a properties file?

A textfile that contains a list of key/value pairs

Study