0% found this document useful (0 votes)
30 views

UNIT I Two Marks

The document discusses key concepts in object-oriented programming and Java including: 1. Objects are instances of classes that represent real-world entities, with classes containing data fields and methods. 2. Features of Java include being simple, platform independent, object-oriented, robust, designed for distributed systems. 3. Classes are important in OOP as they bind related data and methods together, allowing only certain methods to access the data and simplifying error finding and code modification.

Uploaded by

Rayna Ezhil
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

UNIT I Two Marks

The document discusses key concepts in object-oriented programming and Java including: 1. Objects are instances of classes that represent real-world entities, with classes containing data fields and methods. 2. Features of Java include being simple, platform independent, object-oriented, robust, designed for distributed systems. 3. Classes are important in OOP as they bind related data and methods together, allowing only certain methods to access the data and simplifying error finding and code modification.

Uploaded by

Rayna Ezhil
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

UNIT I

INTRODUCTION TO OOP AND JAVA


1. Define objects and classes in Java?
An object is an instance of a class. The objects represent the real-world entity. The
objects are used to provide a practical basis for the real world. Each class is a
collection of data and the functions that manipulate the data. The data components of
class are called data fields and the function components of the class are called
member functions or methods.

2. What are the features of Java?


 Java is simple to implement.
 Java is platform independent.
 It is an object-oriented programming language.
 It is a robust programming language.
 Java is designed for distributed system.

3. Why are classes important in OO technology?
Classes bind together the relative data and methods in a cohesive unit. Due to this
arrangement, only certain methods are allowed to access the corresponding data.
Secondly, if any modification is needed, then the class can be viewed as one module
and the changes made in one class does not spoil rest of the code. Moreover, finding
error from such a source code becomes simple.

4. What is the difference between object and class?

5. What is the difference between static and non-static variables?


A static variable is shared among all instances of class, whereas a non-static variable
(also called as instance variable) is specific to a single instance of that class.
6. Define constructor?
Constructor is a specialized method used for initializing the objects. The name of this
method and the name of the class must be the same. The constructor is invoked
whenever an object of its associated class is created.

7. What is Static in Java?


In java, static is a member of a class that is not associated with an instance of a class.
If there is a need for a variable to be common to all the objects of a single java class,
then the static keyword should be used in the variable declaration.

8. What is the difference between a constructor and a method?

9. What are key characteristics of objects?


 Object is an instance of a class.
 Objects are runtime entities.
 Using object of a class the member variable and member functions of a class can
be accesses.

10. What is Javadoc?


The Javadoc is a standard way to comment the java code. It has a special format of
commenting the java code.

11. Define access specifier.


Access Specifier is used to set the accessibility of class members. There are three
access specifiers in Java
(1) Public
(2) Private
(3) Protected

12. Enumerate two situations in which static methods are used?


The situation in which object of belonging class is not created and we want to use the
method of that class, then the method must be static.
 For calling another static method, one such static method is used.
 For accessing static data, the static method must be used.
13. What are key characteristics of objects?
1. Object is an instance of a class.
2. Objects are runtime entities.
3. Using object of a class the member variable and member functions of a class can
be accesses.

14. List down the basic concept of OOP?


 Object
 Classes
 Data Abstraction
 Data Encapsulation
 Inheritance
 Polymorphism
 Dynamic Binding
 Message Passing

15. What are the differences between ‘break’ and ‘continue’statement?


Break
o Break statement takes the control to the outside of loop.
o It is used in loop and also in switch statement
Continue
o Continue statement takes the control to the beginning of loop.
o It can be used only in loop statement.

16. Differnce between a while and a do-while loop in Java?


UNIT II
INHERITANCE, PACKAGES AND INTERFACES

1. What is the purpose of 'final' keyword?


The keyword 'final' is used to avoid further modification of a variable, method or a
class. For instance, if a variable is declared as final then it cannot be modified further,
similarly, is a method is declared as final then the method overriding is avoided.

2. What is package?
Package represent a collection of classes, methods and interfaces. The name of the
package must be written as the first statement in the Java source program.

3. What is API package?


The API packages are application programming interface packages used by java.
These packages include important classes and interfaces which are used by the
programmer while developing the java applications.
Example: java.io, java.util, java.net etc

4. In Java what is the use of interface?


In java, the interface is used to specify the behaviour of a group of classes. Using
interfaces, the concept of multiple inheritance can be achieved.

5. What is the use of super keyword?


The super class is used to access immediate parent class from the subclass. It is used
to
 Access parent's variable
 Access parent's method
 Access patent's constructor invocation

6. What is meant by dynamic method dispatch?


The dynamic method dispatch is run time polymorphism in which a call to overridden
function is resolved at runtime instead of at compile time.

7. Can an abstract class in Java be instantiated? Give the reason.


The abstract class cannot be instantiated (i.e. we cannot create the object of this class
using new operator) because the abstract class is very much general and less specific.
It does nothing and simply lists out only common features of other classes.
8. Mention the necessity for import statement.
The import statement is used to refer the classes and methods that are present in
particular package. This statement is written at the beginning of any Java program.
For example -import java.io.*
This statement allows to use the useful functionalities for performing input and output
operations.

9. State the condition for method overriding in Java?


Method overriding occurs only when the name of the two methods (method in super
class and method in subclass) are same and their type signature is same.

10. What are the properties of nested interface?


1) Nested interfaces are static by default. You don't have to mark them static
explicitly.
2) Nested interfaces declared inside class can take any access modifier.
3) Nested interface declared inside interface is public implicitly.

11. What is the purpose of nested interface?


The nested interfaces are used to group related interfaces so that they can be easy to
maintain. The nested interface must be referred by the outer interface or class. It can't
be accessed directly.

12. Enlist various forms of inheritance.


Various forms of inheritance are
 Single level inheritance
 Multiple inheritance
 Multi-level inheritance
 Hierarchical inheritance
 Hybrid inheritance

13. What is meant by subclass and superclass?


Subclass: A class which has link to a more general class
Superclass: A class which has one or more members which are classes themselves.

14. Define abstract class?


Abstract class is one that is not used to create objects. An abstract class is designed
only
To act as a base class. It is a design concept in program development and provides a
base upon which other classes may be built.
15. Can an abstract class be final? Why?
The abstract class cannot be final because once we declared the abstract base class
with the keyword final then it cannot be inherited.

You might also like