Definitions

 

Definitions

 

         

Question:

Name any two basic principles of Object-oriented programming.

 

Answer:

Encapsulation and Inheritance.

 

 

Question:

Define abstraction.

 

Answer:

Abstraction refers to hiding the implementation details and only specifying the behaviour of a class. It hides the complexities and only display the essential details.

 

 

Question:

What is Inheritance?

 

Answer:

Inheritance  refers to inherit the variables of another class by extending it. It may also add any additional variables and methods.

 

 

Question:

Why is an object called an instance of a class?

 

Answer:

An object is called an instance of a class because in a class, multiple unique objects can be created.

 

 

Question:

Define Encapsulation.

 

Answer:

Encapsulation refers to the binding of instance variables and methods together in a single unit i.e. binding state and behaviour in a class.

 

 

Question:

Name any two OOP’s principles.

 

Answer:

Two OOPs principles are:

• Encapsulation

• Abstraction

 

Other two are:

• Polymorphism

• Inheritance

 

 

Question:

State the Java concept that is implemented through:

 

(i) a super class and a subclass.

Answer Inheritance

 

(ii) the act of representing essential features without including background details.

Answer: Abstraction

 

 

Question:

Write a Java statement to create an object mp4 of class Digital.

 

Answer:

Digital mp4 = new Digital();

 

 

Question:

What does a class encapsulate?

 

Answer:  

A class encapsulates state(instance variable) and behavior(methods).

 

 

Question:

Complete the code below to create an object of Scanner class: Scanner sc = ____ Scanner(__________);

 

Answer:

Scanner sc = new Scanner(System.in);

 

 

Question:

Define the term Bytecode.

 

Answer:

Bytecode is a set of machine instruction for Java Virtual Machine (JVM).

 

 

Question:

What do you understand by the term data abstraction? Explain with an example.

 

Answer:

Abstraction refers to hiding the implementation details and only specifying the behaviour of a class. It hides the complexities and only display the essential details. Example : mobile phone- we do not know how things are working while we use all the features of mobile easily.

 

 

Question:

Why is an object called an instance of a class? 1 marks

 

Answer:

An object is called an instance of a class because in a class, multiple unique objects can be created.

 

No comments:

Post a Comment