- Java 9 with JShell
- Gastón C. Hillar
- 216字
- 2021-07-09 18:46:50
Test your knowledge
- When Java executes the code within a constructor:
- We cannot access any members defined in the class.
- There is already a live instance of the class. We can access methods defined in the class but we cannot access its fields.
- There is already a live instance of the class and we can access its members.
- Constructors are extremely useful to:
- Execute setup code and properly initialize a new instance.
- Execute cleanup code before the instance is destroyed.
- Declare methods that will be accessible to all the instances of the class.
- Java 9 uses one of the following mechanisms to automatically deallocate the memory used by instances that aren't referenced anymore:
- Instance map reduce.
- Garbage compression.
- Garbage collection.
- Java 9 allows us to define:
- A main constructor and two optional secondary constructors.
- Many constructors with different arguments.
- Only one constructor per class.
- Any new class we create that doesn't specify a superclass will be a subclass of:
java.lang.Base
java.lang.Object
java.object.BaseClass
- Which of the following lines create an instance of the
Rectangle
class and assign its reference to therectangle
variable:var rectangle = new Rectangle(50, 20);
auto rectangle = new Rectangle(50, 20);
Rectangle rectangle = new Rectangle(50, 20);
- Which of the following lines access the
width
field for therectangle
instance:rectangle.field
rectangle..field
rectangle->field
推薦閱讀
- Getting Started with Citrix XenApp? 7.6
- Java范例大全
- 軟件項目管理(第2版)
- 工程軟件開發技術基礎
- C# Programming Cookbook
- Object-Oriented JavaScript(Second Edition)
- Python漫游數學王國:高等數學、線性代數、數理統計及運籌學
- Node.js Design Patterns
- 劍指大數據:企業級數據倉庫項目實戰(在線教育版)
- RealSenseTM互動開發實戰
- 零基礎學Kotlin之Android項目開發實戰
- 編程改變生活:用Python提升你的能力(進階篇·微課視頻版)
- Google Adsense優化實戰
- OpenStack Sahara Essentials
- Splunk Developer's Guide(Second Edition)