1.What is OOPs?
Ans: Object oriented programming organizes a program around its data, i. e. , objects and a set of well defined interfaces to that data. An object-oriented program can be characterized as data controlling access to code.
2.What are Class, Constructor and Primitive data types?
Ans: Class is a template which will define the state and behaviour of the object.class is user defined data type.
class A
{
}
Constructor is special funtion whose name is same as the class name and it helps to define the initial state of the object.
The default return type of constructor is class type.
class integer
{
int m,n;
public:
integer(void) //constructor declared
.....
.....
}
Primitive data types are 8 types and they are: byte, short, int, long, float, double, Boolean, char.
3.What is an Object and how do you allocate memory to it?
Ans: Object is an instance to call the method and properties of the class.The object is created by using new keyword. When an object is created using new operator, memory is allocated to it.
4.What is the difference between constructor and method?
Ans: Constructor will be automatically invoked when an object is created whereas method has to be called explicitly by using dot(.) operator
5.What is the difference between an argument and a parameter?
Ans: At time of defining method, variables passed in the method are called parameters
At time of using those methods, values passed to those variables are called arguments.
6.How many ways can an argument be passed to a subroutine and explain them?
Ans: An argument can be passed in two ways. They are passing by value and passing by reference.
Passing by value: This method copies the value of an argument into the formal parameter of the subroutine.
Passing by reference: In this method, a reference to an argument (not the value of the argument) is passed to the parameter.
7.When we can declare a method as abstract method ?
Ans: When we have to want child class to implement the behavior of the method.
8.Can We call a abstract method from a non abstract method ?
Ans: Yes, We can call a abstract method from a Non abstract method in a Java abstract class
9.What are different types of access modifiers?
Ans: There are following four types of access modifiers
public: Any thing declared as public can be accessed from anywhere.
private: Any thing declared as private can’t be seen outside of its class.
protected: Any thing declared as protected can be accessed by classes in the same package and subclasses in the other packages.
default modifier : Can be accessed only to classes in the same package
10.What is the difference between Assignment and Initialization?
Ans: Assignment can be many times as desired whereas initialization can be only once.
Ans: Object oriented programming organizes a program around its data, i. e. , objects and a set of well defined interfaces to that data. An object-oriented program can be characterized as data controlling access to code.
2.What are Class, Constructor and Primitive data types?
Ans: Class is a template which will define the state and behaviour of the object.class is user defined data type.
class A
{
}
Constructor is special funtion whose name is same as the class name and it helps to define the initial state of the object.
The default return type of constructor is class type.
class integer
{
int m,n;
public:
integer(void) //constructor declared
.....
.....
}
Primitive data types are 8 types and they are: byte, short, int, long, float, double, Boolean, char.
3.What is an Object and how do you allocate memory to it?
Ans: Object is an instance to call the method and properties of the class.The object is created by using new keyword. When an object is created using new operator, memory is allocated to it.
4.What is the difference between constructor and method?
Ans: Constructor will be automatically invoked when an object is created whereas method has to be called explicitly by using dot(.) operator
5.What is the difference between an argument and a parameter?
Ans: At time of defining method, variables passed in the method are called parameters
At time of using those methods, values passed to those variables are called arguments.
6.How many ways can an argument be passed to a subroutine and explain them?
Ans: An argument can be passed in two ways. They are passing by value and passing by reference.
Passing by value: This method copies the value of an argument into the formal parameter of the subroutine.
Passing by reference: In this method, a reference to an argument (not the value of the argument) is passed to the parameter.
7.When we can declare a method as abstract method ?
Ans: When we have to want child class to implement the behavior of the method.
8.Can We call a abstract method from a non abstract method ?
Ans: Yes, We can call a abstract method from a Non abstract method in a Java abstract class
9.What are different types of access modifiers?
Ans: There are following four types of access modifiers
public: Any thing declared as public can be accessed from anywhere.
private: Any thing declared as private can’t be seen outside of its class.
protected: Any thing declared as protected can be accessed by classes in the same package and subclasses in the other packages.
default modifier : Can be accessed only to classes in the same package
10.What is the difference between Assignment and Initialization?
Ans: Assignment can be many times as desired whereas initialization can be only once.
Previous | Next |
:: Click the links below for similar type Questions and answers ::
0 comments:
Post a Comment