Questions and CORRECT Answers
Polymorphism - CORRECT ANSWER - In object-oriented programming, polymorphism
(from the Greek meaning "having multiple forms") is the characteristic of being able to assign a
different meaning or usage to something in different contexts - specifically, to allow an entity
such as a variable, a function, or an object to have more than one form. More specifically, it is
the ability to redefine methods for derived classes. For example, given a base class shape,
polymorphism enables the programmer to define different area methods for any number of
derived classes, such as circles, rectangles and triangles. No matter what shape an object is,
applying the area method to it will return the correct results.
Setter/Getter - CORRECT 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 - CORRECT 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 - CORRECT 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 - CORRECT 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 - CORRECT 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 - CORRECT 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 - CORRECT ANSWER - In computing, the modulo operation
finds the remainder after division of one number by another.
Java/C+ - CORRECT 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 - CORRECT 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.