1~

Minter Coder's Blog

Chapter 2 - Soru 3

2021-03-17

3. Which is correct about an instance variable of type String ?
A. It defaults to an empty string.
B. It defaults to null .
C. It does not have a default value.
D. It will not compile without initializing on the declaration line.

Bir String örnek değişkeni hakkında hangisi doğrudur ?

Hemen basit örnek ;

public class Computer{

      private String computerBrand;

}

Öncelikle instance variablemiz olan computerBrand'ı herhangi bir yere point etmesi için bir değer vermedim ve javada instance variables ve class variablese default değerler atanır.Burada instance variablemizin türü String ve java buna automatic olarak null değerini atar.Cevap B.