An amateur programmer who doesn't like Java very much tried to solve "10 questions to tell if he is a Java programmer"

Introduction

As you can see from past posts, I usually use C ++ or Ruby And as you can see from the title, I ** don't like Java very much ** The reason I hate it is that it was long in the package or namespace and the design pattern was difficult to understand. There may also be initial resistance when touching object-oriented languages from C So Perl is more suitable for sex and is connected to the current Ruby (Perl style and easy to write) It's like that, but I've touched Java often, and I often read sources written in Java. ** I tested how well I understand Java ** The page used for the test is the site below 10 questions to tell if you are a Java programmer

problem

  1. What is the difference between the == operator and the equals method?
  2. Explain the difference between concatenating strings with the + operator and concatenating with StringBuilder.
  3. What is the main purpose of using generic types like List ?
  4. What are the main conditions under which an object is garbage collected (GC)?
  5. Explain the difference between checked and unchecked exceptions in terms of type and exception handling.
  6. Explain the main reason for taking a design policy to refer to a field by making the field access modifier private and providing getter / setter methods.
  7. What are the main situations in which a NullPointerException occurs?
  8. What is the difference between overloading and overriding?
  9. What is a constructor?
  10. Explain one purpose of using the interface

My answer

"==" Is ** a comparison of whether the classes are the same **, and "equals" is ** a comparison of whether the internal data (stored characters for String) are equal **. In Ruby, "==" is basically the same as Java's "equals". 2. "+" ** Recreates a new String that combines two String classes **. StringBuilder is a class that can expand and contract ** Characters are expanded to itself when concatenated with StringBuilder **. An image like the difference between non-destructive and destructive in Ruby 3. ** To be able to use it with various types (classes) **. For example, it is inconvenient that it supports int but not float. That doesn't mean it's okay to define every class, which solves that situation. I'm a C ++ programmer, so I wonder if this is correct 4. When the specified width is exceeded when memory mapping is done? ** I do not know the timing ** 5. ** I don't know the checked and unchecked exceptions because I haven't heard the name itself ** 6. ** Because I don't want the class to use unexpected data **. For example, when the MyString class that holds the number of characters and stored characters meets, writing the number of characters and stored characters at the same time can cause a human error in which the data of each other are inconsistent. Therefore, by using the setter class, the class user does not have to be aware of detailed operations by storing the characters and changing the length of the character string at the same time. 7. ** For example, when referring to Null **, when operating 1 + Null, etc. It is also Ruby. 8. Overloading ** creates methods with the same name with different argument types and numbers in the same class **. Overriding ** overriding methods inherited from the parent class **. I don't know why the definition is overloaded (I feel like overriding) 9. ** First process when creating a class **, Mainly initialization process 10. ** In Java where multiple inheritance is not allowed, methods in the interface can be shared by multiple classes without a parent class ** This makes it suitable for polymorphism design

in conclusion

I said I don't like Java, but I solved some basic problems But it ’s just superficial knowledge, so it ’s probably quite wrong. Kind Java programmers who have seen so far, if you have time, please give me a scoring comment.

Recommended Posts

An amateur programmer who doesn't like Java very much tried to solve "10 questions to tell if he is a Java programmer"
An engineer who doesn't understand Java went to JJUG CCC.