Tuesday, October 10, 2017

CBSE Class 12 - Informatics Practices- Java – Object Oriented Programming (Question and Answers) (#cbseNotes)

Java – Object Oriented Programming (Question and Answers)

CBSE Class 12 - Informatics Practices- Java – Object Oriented Programming (Question and Answers) (#cbseNotes)

Q1:  What is computer programming?

Answer: Computer Programming is a process of designing, writing, testing, debugging and maintaining the source code written in a programming language to solve a real life problem.

Q2: What does it require to write a source code in programming process?

Answer: The process of writing source code of programs requires expertise in subject, knowledge of desired application domain, a formal logic and knowledge of syntax of the relevant programming language.

Q3: What are the two main approaches (methodologies) of programming?

1. Procedural Programming
2. Object Oriented programming.

Q4: What is procedural programming? Give examples of programming languages that support procedural programming.

Answer: In this approach or procedural programming, a programming task is broken into smaller and easily manageable modules (procedures). The stress is given to functionalities rather than data.

Basic, COBOL, Pascal and C Languages supports Procedural Programming approach.

Q5: What is object oriented programming? Give examples of programming languages that support object oriented programming?

Answer: In object oriented programming, a programming task is broken into Objects, which contains data (properties) and its operating methods (behaviours). The main focus is given on Data rater than functions for better security and portability of data.

C++, Java and other modern languages follows this methodology of programming.

Q6: Name the three important features of OOP (Object Oriented Programming).

Answer: In general, Object Oriented Programming (OOP) refers ‘Programming with objects’ , in which programming task is broken into objects.

The main features of OOP are:

1. Encapsulation
2. Polymorphism
3. Inheritance

Q7: Define encapsulation.

Answer: It refers the binding of Data and its associated Methods together in a single unit which is called Object.

Q8: Define Polymorphism.

Answer: A method can perform multiple functionalities (behaviour) depending on the input data. It is performed by Method Overloading and Operator Overloading.

Q9: Define Inheritance.

Answer: The process of deriving a new class (sub class) from existing classes (super class) is called Inheritance. The newly created class may contains properties and behaviour of its parent.

Q10: What are the components of Object Oriented Programming?

Answer: Components of Object Oriented Programming are as follows:
- Class
- Object
- Data Members & Methods
- Access Specifier and Visibility Modes

Q11: What is the basic unit of OOP?

Answer: Class

Q12: What is an instance of a class  called?

Answer: Object

Q13: State the reasons why Java is considered as a pure object oriented programming language.


JAVA is a pure Object Oriented Programming language, since each program in Java must contain at least one class definition.

The basic unit of OOP is the Class. A class represents a set of similar objects. It can be described as a blue print of Objects. In other words, an Object is an instance of a class that holds actual data in memory.

An Object is an entity having a unique Identity, characteristics (Properties) and Behavior (Methods).
JAVA is enriched with various ready-to-use class definitions, which are used in the Application. Swing Controls are collection of such of classes.

For example, JButton control belongs to JButton Class of Swing Control Package. Each time, When you drag JButton on the Frame, an instance (Object) like jButton1, jButton2 etc. is created. Each object (JButton) offers .setText(), .getText() etc. methods, which handles functionalities of the button.

Q14: What is a class? How does it help programmer?

Answer: A class is used to encapsulate data and methods together in a single unit.

It helps the programmer to keep the data members in various visibility modes depending upon what kind of access needs to be provided in the remaining part of the application. These visibility modes are classified as private, public and protected.

Usually, data members of a class are kept in private or protected visibility modes and methods are kept in the public visibility mode.

Q15: What is an object?

Answer: An object is an instance of a class that is capable of holding actual data in memory locations.

Q16: How are classes and objects  related?

Answer: Class and objects are related to each other in the same way as data type and variables.
A 'Class ' describes only specifications while Objects represent the actual and physical entity.

For example, when we declare float variable named marks, the variable marks can be
thought of as an object of type float which can be assumed as the class.

Consider another hypothetical case in which Human is a class, Sakshi Malik, Sachin Tendulkar will be the objects of this Human class.

No comments:

Post a Comment