You are on page 1of 5

NAME: Ahmad Mumtaz

STUDENT ID: F2019346047

Submit to: Gulfraz Naqvi

Quiz 1

Q1.

ANS.

Principles of OOP. The four main principles of object-oriented programming are encapsulation,
abstraction, inheritance, and polymorphism. Binding of data and methods into a single unit is called
encapsulation. Encapsulation is accomplished when each object inside the class keeps its state private.

Q2.

ANS.

Inheritance refers to the assets that an individual bequeaths to their loved ones after they pass
away. An inheritance may contain cash, investments such as stocks or bonds, and other assets such as
jewelry, automobiles, art, antiques, and real estate.

Q3.

ANS.
Declaring a method in sub class which is already present in parent class is known as method
overriding. Overriding is done so that a child class can give its own implementation to a method which is
already provided by the parent class. In this case the method in parent class is called overridden method
and the method in child class is called overriding method. In this guide, we will see what is method
overriding in Java and why we use it.

EXAMPLE:

class Human{

//Overridden method

public void eat()

System.out.println("Human is eating");

class Boy extends Human{

//Overriding method

public void eat(){

System.out.println("Boy is eating");

public static void main( String args[]) {

Boy obj = new Boy();

//This will call the child class version of eat()

obj.eat();

Q4:

ANS:

1. English
You already know English is the lingua fraca in business and global affairs, but how about Tinglish?
Chinglish? Inglish? Most English speakers in the world today aren’t native English speakers, and most of
the people they speak English with aren’t native speakers either. This results in many situations where
the variants of English they speak drift considerably from the native-speaking forms.

To learn English as it is spoken as a common global language, you have to learn to be explicit, avoid
idiom, and alter your pronunciations and expectations. Functionality becomes more important than
form and cultural neutrality is your goal. This won’t satisfy your master’s program language
requirement, but there’s a good chance you’ll use it far more frequently than any fully recognized
foreign language on the list.

2.Chinese

We’re not just cribbing this from Looper. Chinese really is the language of the future. Although
estimates vary on how many native Chinese speakers there are in the world today, all of them start
north of a billion. That makes it the most commonly spoken language on the planet, and if it’s not
widelyspoken yet, that day is coming.

Q5.

ANS:

#include<iostream>

using namespace std;

int main()

cout<<"Hello World!";

return 0;

Q6.

ANS:

Inheritance hierarchies, interfaces, and polymorphism are different variants of the same object-
oriented idea: objects can present themselves from different angles as they take one type or another.
For the user of objects, only the type and not the concrete implementation plays a role.
From the developer's perspective, this idea results in a number of benefits, while the tester has to
struggle with the traps of complexity hidden behind the cloak of simplicity.

This chapter discussed both the theoretical foundations for a better understanding of the problems
involved in inheritance and polymorphism and techniques to solve some of these problems. These
techniques include reuse of the superclass tests and testing of interfaces.

Q7.

ANS:

The main difference between Class and Structure is that the Class is a reference type data type
while the Structure is a value type data type.

Q8.

ANS:

1. A class can have subclasses that can inherit all or some of the characteristics of the class. In
relation to each subclass, the class becomes the superclass.

2.Subclasses can also define their own methods and variables that are not part of their superclass.

Q9.

ANS:

1a: something material that may be perceived by the senses

I see an object in the distance.

b: something that when viewed stirs a particular emotion (such as pity)

Look on the tragic loading of this bed … the object poisons sight; let it be hid.

— William Shakespeare
Q10.

ANS:

A constructor is a special method of a class or structure in object-oriented programming that initializes a


newly created object of that type. Whenever an object is created, the constructor is called
automatically.

A constructor is like an instance method that usually has the same name as the class, and can be used to
set the values of the members of an object, either to default or to user-defined values. However,
although it resembles it, a constructor is not a proper method since it doesn’t have a return type.
Instead of performing a task by executing code, the constructor initializes the object, and it cannot be
static, final, abstract, and synchronized.

You might also like