Q. What is a class variable?
Ans: Static keyword in Instance
variables is called a class variable. For every object there is just one copy
of the variable made.
Ex.
class Summation
{
static
int a;
static
int b;
}
Q. What is significance of import
java.io.* in your program?
Ans: The line imports all the
classes of the java.io package into the program.
Q. State the two kinds of data
types.
Ans: The two kinds of data types
in Java are primitive and reference data types.
Q. Define impure function.
Ans: Impure Function: A function
that brings about a change in the argument that it receives. Its arguments will
always be reference types. It may or may not return value. In other words, an
impure function brings about a change in the state of the function. This change
in state is called the side effect of calling an impure function.
Example:
Static void count(Number
num)
{
num.counter=num.counter+1;
}
Q. What are comments? Name the
different types.
Ans: Comments are statements
which enhances the readability and understanding of the program. They are not
part of the program.
The different types are: single
line (//….), multiple line (/* … */) and documenting comment (/**….*/).
Q. Define Encapsulation.
Ans: The wrapping of data and
function together into a single unit is called Encapsulation.
Q. Name any three OOP’s
principles
Ans: Inheritance, Polymorphism and Encapsulation
Q. Define Object with example.
Ans: Object: An instance of a class called Object.
Table is an instance of class Furniture.
Class: Blue print of an object is
called Class. Example, mango, apple and orange are members of the class fruit.
Q. What is wrapper class? Give
example.
A wrapper class is a class which
wraps a primitive data type. Example Double, Float, Integer
Q. What is meant by private
visibility of a method?
Ans: The visibility of private method restricted
to class itself. It is not visible to anywhere outsite the class.
Q. What is a variable?
Ans: A variable is a named memory
location whose value can change. Example int a,b;
Q. What is the use of return
keyword?
Ans: A return keyword is used to
return any value from a function. It denotes the end of a function.
Q. What is call by value?
Ans: In call by value arguments
are passed by the value, which means that a copy of the arguments is passed to
the method can make changes to the value of this copy but can not change the
values of the original variables in the calling method.
Q. What is meant by an infinite
loop? Give an example.
Ans: An infinite loop is a loop
whose test condition is always true. This type of loop never ends by itself.
For example:
for(i=1;i>0;i++)
{
System.out.println(“Hello”);
}
Q. State any two objectives of
using Arrays.
Ans: 1. Use hold elements in contiguous memory
location. 2. Arrays are used to group storage locations.