[Solved] Basic Java OOP Questions on variable declaration and access


Question 1:
Honestly, this is the most basic practical object-oriented question out there. If you don’t understand it, you need to go talk to someone.

True or False: Local variables may be declared private.
Local variables can never be accessed by outside code; it makes no sense to declare them private.

True or False: Formal parameters may be declared to be final.
True – it means that the method can’t reassign the parameter locally.
/* Edited according to the comment below */

True or False: Declaring an object (for example, Person p;) allocates space for that object
Objects in java are all references. When you declare an object, it allocates a reference which doesn’t refer to anything in particular. When you later allocate the object, it then sets that reference to point to an allocated section of memory in which the object is stored.

3

solved Basic Java OOP Questions on variable declaration and access