Java8 Silver exam memorandum

Even if I develop it in Java, there are many places I use it without knowing it well.

Array

Initialization

int[] arrayInt = new int[2];
System.out.println(arrayInt .length); //2 is displayed
for (int i : arrayInt ) {
    System.out.println(i); //0 is displayed
}

String[] arrayStr = new String[2];
System.out.println(arrayStr.length); //2 is displayed
for (String str : arrayStr) {
    System.out.println(str); //null is displayed
}
int[] arrayInt = new int[2] { 1, 2 }; //Compile error

Pass by reference

int[] array1 = new int[1];
int[] array2 = { 1, 2, 3 };
array1 = array2;
for (int i : array1) {
    System.out.println(i); // 1, 2,Is displayed as 3
}

copy

int[] array1 = { 1 };
int[] array2 = array1.clone();
array2[0] = 2;
System.out.println(array1[0]); //1 is displayed
System.out.println(array2[0]); //2 is displayed

Comparison

StringBuilder sb = new StringBuilder(5);
String str = "";
System.out.println(sb.equals(str)); //False for reference comparison
System.out.println(sb.toString().equals(str)); //True for value comparison

Polymorphism

interface A {
    void test1(); //public is automatically attached
    void test2(); //public is automatically attached
}

abstract class B implements A{
    abstract void test3(); //public cannot be attached automatically
                           //Private qualification is not possible
}

class C extends B{
    public void test1(){} //Compile error if not defined
    public void test2(){} //Compile error if not defined
    public void test3(){} //Compile error if not defined
}

public class test {
    public static void main(String[] args) {
        A a = new A(); //Compile error
        B b = new B(); //Compile error
        C c = new C();
    }
}

Overload

public static void main(String[] args) {
    test(1, 2);
}

private static void test(int... i) {
    System.out.println("A");
}

private static void test(int i, int j) { //Called
    System.out.println("B");
}

loop

abbreviation for while

int i = 0;
do
    System.out.println("A");
    i++; //Compile error because multiple lines cannot be written in the abbreviated format
while (i < 3);

initialization of for

for (int i = 0, j = 0; i < 5; i++) {
    System.out.println("A");
}

for (int i = 0, int j = 0; i < 5; i++) { //Compile error
    System.out.println("A");
}

Recommended Posts

Java8 Silver exam memorandum
Java8 Gold exam memorandum
JAVA Silver qualification exam record
Java memorandum
Java Silver memo
Java memorandum (list)
Java study memorandum
Study Java Silver 1
[Java] Optional memorandum
Java Silver exam procedure and learning method
Java Silver Exam Reservation Complete Strategy Guide
Passed Java SE8 Silver
java bronze silver passed
Java Silver Study Day 1
Java Silver passing experience
Summarize Java inheritance (Java Silver 8)
[java] Java SE 8 Silver Note
[Java Silver] About initialization
About inheritance (Java Silver)
[Qualification Exam] Java SE 8 Silver Learning Method Summary
Java SE 8 Sliver exam questions
[Experience] Passed Java SE 8 Silver
Java Silver Study Method Memo
JAVA qualification exam preparation materials
Java 3 major elements (object-oriented) memorandum
Java SE8 Silver Pass Experience
[Java Silver] Array generation method
How to study Java Silver SE 8
Get Java Silver on your commute!
Road to Java SE 11 Silver acquisition
I fell into Java Silver (crying)
memorandum
Java Silver Repo (Failure & Pass Experience)
Java
Java SE Bronze exam test content
Java Silver Immediately before taking the exam / Trigger question check sheet
How to pass Oracle Java Silver
memorandum
Java
What I learned with Java Silver
Diary for Java SE 8 Silver qualification
[Qualification] Java Silver SE11 Passing Experience
[Java Silver] Summary of access modifier points
Passed the Ruby Technician Certification Exam Silver
Memorandum of new graduate SES [Java basics]
Java SE8 Silver ~ The Road to Pass ~
How to use submit method (Java Silver)
Oracle Certified Java Silver SE 8 Passing Experience
[Creating] A memorandum about coding in Java
Java SE 8 Silver (Java SE 8 Programmer I) Pass Note
Ruby Technician Certification Exam Silver Examination Note
Inexperienced learning methods to get Java Silver 11
The story received by Java SE11 silver
I tried Google's entrance exam (unofficial) [java]