Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Object class subtleties  RSS feed

chetan nain
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. equals() is overridden by :Boolean , Character , Integer , Long , Float , Double ,
String , and Bitset classes. it is NOT overridden by StringBuffer.Application of
equals() to classes not overriding it will yield same result as ==.
2.The equals method defined by class Object for any reference values x and y, returns true if and only if x and y refer to the same object.
Overridden by Boolean, Character, Integer,Long, Float,Double,
String, and Bitset.

3.The general contract of hashCode is as follows:
Whenever it is invoked on the same object more than once during an execution of a Java application, hashCode will return the same value.
If two objects are equal according to the equals method , then calling the hashCode method on each of the will produce same result
Copying an object by clone() method will typically entail creating a new instance of its class, but it also may require copying of internal data structures as well.
4. There is no public constructor for the class Class. The Java Virtual Machine automatically constructs Class objects as
classes are loaded; such objects cannot be created by user programs.
5. public static void gc()
Calling this method SUGGESTS that the JVM expend effort toward recycling discarded objects. in context of certification exam, we can only SUGGEST, not FORCE garbage collection.
any more suggestions?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!