2026 QUESTIONS WITH SOLUTIONS GRADED
A+
◉ Setter/Getter. Answer: Getter and setter methods are used to retrieve
and manipulate private variables in a different class. A "getter" method
does as it name suggest, retrieves a the attribute of the same name. A
"setter" method allows you to set the value of the attribute.
◉ Setter/Getter Use. Answer: The reason to use getter and setter
methods rather than just making the member variables public is because
of the principle of information hiding - classes should not reveal their
innards to the outside world, because that tightly couples the
implementation of the class to whatever is in the outside world. That's
bad, because if you tightly couple lots of classes together in a larger
program, the program will become a big, entangled mess that's hard to
maintain.
◉ Override. Answer: Two methods with the same method name and
parameters (i.e., method signature). Vertical along parent-child
hierarchy. Takes place at different levels of inheritance but involves
functions with the SAME name and the SAME number/type of
parameters.
,◉ Overload. Answer: Method overloading is the ability to define several
methods all with the same name. Horizontal - takes place at the SAME
level of inheritance within a class hierarchy. Same name but different
types/number of parameters.
◉ Stored Procedure. Answer: The real power of stored procedures is the
ability to pass parameters and have the stored procedure handle the
differing requests that are made.
CREATE PROCEDURE dbo.uspGetAddress @City nvarchar(30)
AS
SELECT *
FROM Person.Address
WHERE City = @City
GO
EXEC dbo.uspGetAddress @City = 'New York'
◉ Constructor in Java. Answer: A constructor in Java is a block of code
similar to a method that's called when an instance of an object is created.
◉ Modulo/Modulus Operator. Answer: In computing, the modulo
operation finds the remainder after division of one number by another.
, ◉ Java/C+. Answer: C++ is platform-dependent. Java is platform-
independent. C++ is mainly used for system programming. Java is
mainly used for application programming. It is widely used in window,
web-based, enterprise and mobile applications. C++ supports multiple
inheritance.Java doesn't support multiple inheritance through class. It
can be achieved by interfaces in java. C++ supports operator
overloading.Java doesn't support operator overloading.
◉ Checked/Unchecked Exception. Answer: Checked exceptions − A
checked exception is an exception that occurs at the compile time, these
are also called as compile time exceptions. These exceptions cannot
simply be ignored at the time of compilation, the programmer should
take care of (handle) these exceptions.
Unchecked exceptions − An unchecked exception is an exception that
occurs at the time of execution. These are also called as Runtime
Exceptions. These include programming bugs, such as logic errors or
improper use of an API. Runtime exceptions are ignored at the time of
compilation.
◉ Exception and uses. Answer: An exception (or exceptional event) is a
problem that arises during the execution of a program. When an
Exception occurs the normal flow of the program is disrupted and the
program/Application terminates abnormally, which is not recommended,
therefore, these exceptions are to be handled.