Interview QC Questions Part 2 Flashcards
How have you used inheritance?
We once created a base Animal class with varying variables and attributes. We then created a Cat class that extended the base Animal class allowing us to call those attributes from the Animal class such as getEats or getNoOfLegs.
What is polymorphism? Explain Method Overloading.
Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.
If a class has multiple methods having same name but different in parameters, it is known as Method Overloading. Suppose we have a class called, “Animal” and two child classes, “Cat,” and “Dog.” If the Animal class has a method to make a noise, called, “makeNoise,” then, we can override the “makeNoise” function that is inherited by the sub-classes, “Cat” and “Dog,” to be “meow” and “bark,” respectively.
What is the difference between an Error and an Exception?
An error is an irrecoverable condition occurring at runtime. Such as OutOfMemory error. Exceptions are conditions that occur because of bad input etc. e.g. FileNotFoundException will be thrown if the specified file does not exist.
What are the Scopes of Java variables? Explain Scopes.
Every variable used in a programming language holds a scope. The scope tells the compiler about the segment within a program where the variable is accessible or used.
- block scope (a local var within a for loop)
- method scope (method vars only exist within the method: static/instance)
- class, or static scope (vars changes reflected across all instances of a class; static keyword)
- instance, or object scope (instance variable is attached to individual objects created from the class)
What is Abstraction? What is the difference between an Interface and an abstract class?
Abstraction means showing only the relevant details to the end-user and hiding the irrelevant features that serve as a distraction. An abstract class allows you to create functionality that subclasses can implement or override. An interface only allows you to define functionality, not implement it
Where are variables stored in memory?
In Java all objects are dynamically allocated on Heap. When an Objects is allocated using new(), the object is allocated on Heap, otherwise the Object is allocated on a Stack if not global or static.
What is a wrapper class?
A Wrapper class is a class which contains the primitive data types (int, char, short, byte, etc).
Wrapper classes provide a way to use primitive data types as objects. These wrapper classes come under java.util package.
What is a package in java?
A java package is a group of similar types of classes, interfaces and sub-packages.
Package in java can be categorized in two form, built-in package and user-defined package.
There are many built-in packages such as java, lang, awt, javax, swing, net, io, util, sql etc.
Java package is used to categorize the classes and interfaces so that they can be easily maintained.
Java package provides access protection.
Java package removes naming collision.
What is a Static method?
In Java, a static method is a method that belongs to a class rather than an instance of a class. The method is accessible to every instance of a class, but methods defined in an instance are only able to be accessed by that object of a class.
What is a relational database?
A relational database uses a structure that allows us to identify and access data in relation to another piece of data in the database.
What is DDL?
Data Definition Language
– Used to define Database objects like TABLE, VIEW,SEQUENCE,INDEX,SYNONYM creation or modification or removing.
–CREATE,ALTER,DROP,TRUNCATE,RENAME are the DDL commands
What is DML?
Data Manipulation Language
-Used to manipulate the data in Database objects like table, view, index ..etc,.
-INSERT, UPDATE, DELETE are the DML commands.
What is DQL?
Data Query Language
-used to retrieve information from the database objects. it is for read only purpose.
– SELECT is the DQL or DRL command.
What is DCL?
Data Control Language
Data control statements are use to give privileges to access limited data or share the information between users.
-GRANT,REVOKE ,AUDIT,COMMENT, ANALYZE are the DCL commands.
What is TCL?
Transaction Control Language
-Transaction control statement are use to apply the changes permanently save into database.
-COMMIT, ROLLBACK, SAVEPOINT, ROLLBACK TO are the TCL commands.