Computer Knowledge

Java Core Classes and Threads

1,935 Questions

Java core classes and threads form the foundation of object oriented programming and are crucial for IT officer and programming exams. This includes concepts like string mutability, collections, and multithreading. Solve these questions to test your practical coding and theoretical knowledge.

String and StringBuffer classesThread execution methodsJava collections frameworkCharacter streams input outputVariable serialization rules

Java Core Classes and Threads Questions

Multiple choice
  1. to pre allocate space for a certain number of characters after a string buffer is constructed

  2. to determine whether a given string begins with a specified string

  3. to find the total allocated capacity of the stringbuffer

  4. to find the correct length of the stringbuffer

  5. to set the length of the stringbuffer

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

This is the characteristic of the method ensurecapacity().

Multiple choice
  1. It provides the format specific to the strings.

  2. It is used to denote an object.

  3. It specifies the new value should be sent -retain on assignment and the old value sent release.

  4. It specifies the new value should be sent -copy on assignment and the old value sent release.

  5. It returns the class and memory address of the object.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

NSLog() uses format specifiers to indicate substitution tokens, just like the C standard library printf() function.

Multiple choice
  1. Its is used to retain the assigned value and release the previously set value.

  2. It makes the compiler NOT check what other threads are executing over the value at the same time.

  3. It is used to create automatically the setter and the getter methods for the property.

  4. The “retain” property is needed when the attribute is a pointer to an object.

  5. Both 1 and 4

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

These are correct statements about 'retain' attribute in Objective C property.

Multiple choice
  1. The dealloc method is called on an object when it is being removed from memory.

  2. This method is called automatically by the runtime.

  3. The dealloc method is not called on objects, if garbage collection is enabled.

  4. The [super dealloc] is used to ask the superclass to do its cleanup. If one does not do this, the object will not be removed.

  5. This method is used to set initial values for the instance variables.

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

This is true about initial method, dealloc() is used to delete the memory objects.