1~

Minter Coder's Blog

Chapter 2 - Soru 50

2021-03-18

50. What is the output of the following?

package beach;
public class Sand {
    public Sand() {
     System.out.print("a");
    }
   public void Sand() {
     System.out.print("b");
   }
   public void run() {
     new Sand();
     Sand();
   }
  public static void main(String... args) {
    new Sand().run();
  }
}
A. a

B. ab
C. aab
D. None of the above

Çıktı aab // birinci a harfi main methodunun içerisinde oluşturulan Sand nesnesi diğeri ise run methodunun içerisindeki nesne ve b harfi ise Sand/( methodunu çağırmayla çalışır cevap C.