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.
Questions
Question 1 Multiple Choice (Single Answer)
Overriding and Overloading is for ?
- Methods and variables
- Class
- Variables
- Methods
Question 2 Multiple Choice (Single Answer)
For a subclass outside the package, the protected member can be accessed through ?
- Object of super class
- Inheritance
- Both
- None
Question 3 Multiple Choice (Multiple Answers)
Which, inserted independently at line 6, will compile? (Choose all that apply.)
- static void doStuff(int... doArgs) { }
- static void doStuff(int x, int... doArgs) { }
- static void doStuff(int[] doArgs) { }
- static void doStuff(int... doArgs, int y) { }
Question 4 Multiple Choice (Single Answer)
Which variables have the longest scope?
- Block variables
- Instance variables
- Static variables
- Local variables
Question 5 Multiple Choice (Multiple Answers)
Which are the default value for the Primitives and Reference Types ?
- Object reference =null
- double =0.0
- byte=0
- 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?
- Two objects are eligible for GC
- Five objects were created
- Four objects were created.
- Three objects are eligible for GC
Question 7 Multiple Choice (Single Answer)
What will be the output?
- y string = Java,y string = Java
- y string = Javay string = Java
- y string = Java, y string = Java
- y String = Java, y string = Java