Professional Documents
Culture Documents
ans. An object is an identifiable entity with some characterstics and behavior. variable declared of a class
is called an object
ans. A class is a blueprint that represents a set of similar objects and their behavior. for eg.
class student
int roll,hindi,english,maths,social,science;
String name,sclass,sec,city;
roll=rr;
name=nn;
sclass=cc;
sec=ss;
city=ct;
void getresult()
void printdata()
{
System.out.println("Roll is"+roll);
in the above diagram student is a class which is a collection of variable methods and data members.
ans. access specifiers are the keywords used to determine the tpe of access to the method or variable.
there are four types of access specifiers
Ans.
A method prototype of signature is a model or declartion of method which identifies the parameters
and return type of that method.
for eg. int sum(int p,int q) // this prototype is indicating that the function sum will return an integer
and takes two integers as parameters
Q6. What are actual and formal parameters ?
Ans.
Actual Parameters - these are the parameters that are actually passed to a function call.
Formal Parameters - these are the parameters that are received during the function defination.
for eg.
int r;
r=p+q;
return(r);
int a,b,c;
a=6;
b=3;
System.out.println("sum is "+c);
Ans.
Call by value : In this method copy of actual parameters are passed into the formal parameters and
whatever changes are made in formal parameters are not reflected back to the actual parameters.
Call by reference : in this method reference of actual parameters is passed into the formal paramters
and whatever changes are made in formal parameters are reflected back to the actual parameters.
normally it has object as function arguments.
Q8. What is scope and lifetime of a variable ?
Ans. The program part i which a particular piece of code or a data value can be accessed is known as
scope. visibility is also referred to as scope. Lifetime of a variable refers to the time to which a variable
lives in the program.
Ans. A function having the same name as of the class is called a constructor. It is called automatically
upon creation of object of that class. It is used for initialization of data members of the class.
Ans. The keyword "THIS" refers to the currently calling object. It is automaically created and initialized
by Java.
Ans.
String String Buffer
----------------------------------------------------- -----------------------------------------------------
2. String Object once created can't be changed StringBuffer objects can be changed,
modified as desired
3. It contains less number of methods as compare to StringBuffer StringBuffer contains a large set
of additional methods to modify strings.
Ans. Packages are groups of related classes and interfaces related to a particular category. Java has a
large set of inbuilt packages like java.io.*, java.sql. etc.
We can also create our own packages. To include a package in a program we have to use import
statement at the top of program.
Ans. It is the most important concept of Object oriented programming. Inheritance is the capabiity of
one class to inherit properties and methods from an another class. Major objective of inheritance is
resuability
1. Single inheritance
2. Multiple inheritnce
3. Multilevel Inheritance
4. Hierarchical Inheritance
5. Hybrid Inheritance
NOTE : multiple and hybrid inheritance is not supported in java. we have to use interfaces to implement
them.
Ans. A derived class or a subclass is the class which inherits the properties and methods of another class
Ans. A Base class or a superclass is the class which is derived into an another class.
Ans. A variable whose value can't be changes is called final variable. it is declared as follows :
Ans. An abstrat class is the once that simply represents a concept and whose objects can't be created. It
is created through the use of keyword abstract.
ans. Interface is just like abstract class, it is used to implements multiple inheritance in java.
Ans. It refers to the concept where a class contains more than one methods with same name but with
different signatures.
RadioButton Checkbox
---------------------------------------------------------------------------------------------------------------------------
1. Only one of multiple radiobuttons can be selected more than once checkboxes can
be selected among multiple checkboxes
PasswordField TextField
------------------------------------------------------------------------------------------------------------------------
1. Characters written in this are encrypted characters are visible as they
are written
LISTBOX ComboBox
-----------------------------------------------------------------------------------------------------------------------------------
1. More than one items are displayed at a time Only one item can be displayed
at a time.
2. More than one items can be selected at a time Only one item can be selected
at a time.
TextField TextArea
------------------------------------------------------------------------------------------------------------------------------------