Java Fundamentals - Methods, Variables, and Memory Management

Test your knowledge of core Java programming concepts including method overriding and overloading, access modifiers, variable scope, default values, garbage collection, and string handling.

7 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Overriding and Overloading is for ?

  1. Methods and variables
  2. Class
  3. Variables
  4. Methods
Question 2 Multiple Choice (Single Answer)

For a subclass outside the package, the protected member can be accessed through ?

  1. Object of super class
  2. Inheritance
  3. Both
  4. None
Question 3 Multiple Choice (Multiple Answers)

Which, inserted independently at line 6, will compile? (Choose all that apply.)

  1. static void doStuff(int... doArgs) { }
  2. static void doStuff(int x, int... doArgs) { }
  3. static void doStuff(int[] doArgs) { }
  4. static void doStuff(int... doArgs, int y) { }
Question 4 Multiple Choice (Single Answer)

Which variables have the longest scope?

  1. Block variables
  2. Instance variables
  3. Static variables
  4. Local variables
Question 5 Multiple Choice (Multiple Answers)

Which are the default value for the Primitives and Reference Types ?

  1. Object reference =null
  2. double =0.0
  3. byte=0
  4. char = '\u0000'
Question 6 Multiple Choice (Multiple Answers)

Which two are true about the objects created within main(), and eligible for garbage collection when line 14 is reached?

  1. Two objects are eligible for GC
  2. Five objects were created
  3. Four objects were created.
  4. Three objects are eligible for GC
Question 7 Multiple Choice (Single Answer)

What will be the output?

  1. y string = Java,y string = Java
  2. y string = Javay string = Java
  3. y string = Java, y string = Java
  4. y String = Java, y string = Java