OCP open points
some open points
some open points
Set of flashcards Details
Flashcards | 90 |
---|---|
Language | Deutsch |
Category | Computer Science |
Level | Other |
Created / Updated | 09.01.2020 / 10.01.2020 |
Weblink |
https://card2brain.ch/box/20200109_ocp_open_points
|
Embed |
<iframe src="https://card2brain.ch/box/20200109_ocp_open_points/embed" width="780" height="150" scrolling="no" frameborder="0"></iframe>
|
Create or copy sets of flashcards
With an upgrade you can create or copy an unlimited number of sets and use many more additional features.
Log in to see all the cards.
Ändert das casten das Objekt?
Nein, nur wie der Compiler das Objekt sieht
Sind aufrufe von non-private und non-final instance-methods dynamisch von der jvm (also virtuell) oder staisch zur compile-zeit gebunden?
Dynamisch von der jvm -> polymorphismus wäre sonst nicht möglich, Elemente zur Laufzeit austauschen
Kann man die equals-methode auch "nur" overloaden statt overriden?
Ja, super gefährlich - Verwendet man die Methode kann es sein, dass die equals-methode der superklasse aufgerufen wird
Was ist alles in einem Interface defaultmäßig?
public außer Methoden di eexplizit private sind
Was ist der Unterschied zwischen statischen Methoden einer Klasse und eines Interfaces hinsichtlich der vererbung?
statische methoden eines interfaces werden nicht vererbt, einer Klasse schon
Was passiert wenn eine Klasse von zwei interfaces eine Methode mit derselben Signatur erbt, in einem interface ist sie allerdings default (also schon implementiert)?
Die Klasse muss sie dennoch selbst implementieren (gleich wie wenn kein default oder beide default)
Zu welcher Kategorie von Klassen gehört ArrayList?
Zu den collections
Was ist der Unterschied zwischen ArrayList.size() und ArrayList.capacity()?
size its die Anzahl elemente in der ArrayList und capacity die Länge des Arrays
Ist eine Map auch eine Collection?
Nein
Was ist jdeps?
Der Java class dependency analyzer
Kann eine überschreibende Methode die Methode final machen?
Ja
What will the following code print when run?
class A {
}
class AA extends A {
}
public class TestClass {
public static void main(String[] args) throws Exception {
A a = new A();
AA aa = new AA();
a = aa;
System.out.println("a = "+a.getClass());
System.out.println("aa = "+aa.getClass());
}
}
a = class AA
aa = class AA
-> nimmt die Methode des Objektes das referenzier twird -> a und aa referenzieren beide dasselbe Objekt!
What will be the result of attempting to compile and run the following program?
public class TestClass{
public static void main(String args[ ] ){
A o1 = new C( );
B o2 = (B) o1;
System.out.println(o1.m1( ) );
System.out.println(o2.i );
}
}
class A { int i = 10; int m1( ) { return i; } }
class B extends A { int i = 20; int m1() { return i; } }
class C extends B { int i = 30; int m1() { return i; } }
30,20 :
Which variable (or static method) will be used depends on the class that the variable is declared of.
Which instance method will be used depends on the actual class of the object that is referenced by the variable.
Consider the following code:
class A{
A() { print(); }
void print() { System.out.println("A"); }
}
class B extends A{
int i = 4;
public static void main(String[] args){
A a = new B();
a.print();
}
void print() { System.out.println(i); }
}
What will be the output when class B is run ?
0, 4
Note that method print() is overridden in class B. Due to polymorphism, the method to be executed is selected depending on the class of the actual object.
Here, when an object of class B is created, first B's default constructor (which is not visible in the code but is automatically provided by the compiler because B does not define any constructor explicitly) is called. The first line of this constructor is a call to super(), which invokes A's constructor. A's constructor in turn calls print(). Now, print is a non-private instance method and is therefore polymorphic, which means, the selection of the method to be executed depends on the class of actual object on which it is invoked. Here, since the class of actual object is B, B's print is selected instead of A's print. At this point of time, variable i has not been initialized (because we are still in the middle of initializing A), so its default value i.e. 0 is printed.
validateEmployee(e, e->e.age<10000)
wäre das ok?
Nein:
Remember that the parameter list part of a lambda expression declares new variables that are used in the body part of that lambda expression. However, a lambda expression does not create a new scope for variables. Therefore, you cannot reuse the local variable names that have already been used in the enclosing method to declare the variables in you lambda expression. It would be like declaring the same variable twice.
Here, the main method has already declared a variable named e. Therefore, the parameter list part of the lambda expression must not declare another variable with the same name. You need to use another name. For example, if you change //3 to the following, it will wor
Was bedeutet "multiple inheritance of state"?
Dass Felder von mehreren Klassen geerbt werden können. Geht in Java nicht.
Was bedeutet multiple inheritance of implementation?
Dass Implementierungen von Methoden von mehreren Klassen geerbt werden können. Gibt es in java bswp mit default/static-methoden in interfaces
Was ist multiple inheritance of type?
Dass eine Klasse mehrere Interfaces implementieren kann
Wie geht die Subtype-hierarchie bei generics mit extends (A<? extends S) .. ?
A<S> <<<<< A<? extends S> <<<<< A<? extends T>
z.B. Integer <<< Number, List<Integer> <<<< List<? Extends Integer> <<< List<? Extends Number>
Wie geht die Subtype-hierarchie bei generics mit super (A<? super T) .. ?
A<T> <<< A<? super T> <<< A<? super S>
z.B. List<Number> <<< List<? Super Number> <<< List<? Super Integer>
Können statische Methoden zusätzlich abstrakt sein?
Nein!
Kann man das default-package importieren?
Nein, etwas wie import *; existiert nicht
Was gibt es für Optionen um ein statisches Feld aus einer Klasse zu importieren? z.B.:
package taxes;
public class Values {
public static double TAX_RATE = 0.15;
}
1. Über den FQN nutzen: taxes.Values.TAX_RATE;
2. import taxes.Values; oder import taxes.*; dann: Values.TAX_RATE
3. import static taxes.Values.TAX_RATE; oder import static taxes.Values.*; dann einfach TAX_RATE
Welches Package wird immer automatisch importiert?
java.lang
Ist java statisch oder dynamisch typisiert?
statisch, dynamisch typisierte können den datentyp zur runtime ändern
Wertebereich byte
-128 bis 127
Wertebereich char
0 - 65535
Wertebereich short
-32768 bis 32767
Wertebereich int
-2^31 - 2^31-1
Wertebereich long
-2^63 - 2^61-1
-
- 1 / 90
-