CHAPTER 5_COMPUTER
CHAPTER 5_COMPUTER
Question 1
Question 2
Question 3
A Class is a blueprint that defines data and functions common to all objects of a certain kind.
Question 4
Question 5
Question 1
Question 2
Constants mean the fixed values that do not change during the execution of a program.
True
Question 3
The main() function indicates that the execution of the Java program will begin from this point.
True
Question 4
Question 5
Inheritance is a feature using which an object in one class acquires the properties of another class.
True
Question 6
While comparing two variables, their data types should not be the same.
False
Question 1
Ritika has written a program in Java. After the successful compilation of her program, which option
should she select to run it?
Answer
To run her program, Ritika needs to right-click on the class icon and select void main(String[] args) option
from the pop-up menu.
Question 2
Kareena is writing a program in Java to calculate the average of three subjects. Which operators will she
use for the same?
Answer
Kareena will use the addition operator (+) to first calculate the total marks obtained in all three subjects.
After that, she will use the division operator (/) to divide the total marks by 3 to get the average.
Question 1
1. Identifier
2. Keyword
3. Variable ✓
Question 2
Question 3
Which among the following feature is used to manage the complexity of the system?
1. Abstraction ✓
2. Polymorphism
3. Encapsulation
Question 4
1. Source Code
2. Bytecode ✓
3. None of these
Question 5
1. Unary Operator ✓
2. Arithmetic Operator
3. Relational Operator
Question 6
1. ?
2. + ✓
3. !
Question 1
Define objects. Give a real life example to explain objects along with their attributes and behaviour.
Answer
An object represents data (attributes) and its related methods (behaviour) as a single unit. Take the
example of a car. When we describe a car as an object, there are a number of physical factors which
contribute to define its state such as its brand name, colour, speed, size, number of seats, etc. In
addition, the car has several functional definitions. It transports people to different locations by
controlling its speed and direction, an accelerator to increase or decrease its speed and brakes to stop it.
Thus we can say that car is an object that combines its attributes and behaviour as a single unit.
Question 2
What is class?
Answer
A class is a blueprint to create objects. It defines data and functions common to all objects of a certain
kind.
Question 3
Answer
The word Polymorphism means "many forms". Polymorphism helps the programmer to use the same
function name for more than one purpose.
Question 4
Answer
Operators are special symbols that are used to perform calculations. We need operators to form
expressions by applying them to the variables and constants.
Question 5
Answer
Keywords are reserved words that have a special meaning for the Java compiler. Java compiler reserves
these words for its own use so Keywords cannot be used as identifiers. For example, void, public, class,
int, etc.
Question 6
Answer
A variable is a named location in the memory which stores data temporarily. A variable has a unique
name, a type and a size that is used to identify it in a program.
Difference between variables and constants is that the value of variables can change during the
execution of the program whereas value of constants are fixed and does not change during program
execution.
Lab Session
Question 1
Output
Question 2
Write a program to print your Name, Class, Roll_No, Marks and Age. Name this file, `MyProfile'.
System.out.println("Class: 8C");
System.out.println("Marks: 87");
System.out.println("Age: 15");
Output
Question 3
Write a program to print your School name four times in separate lines.
Output
Question 4
int sum = a + b + c;
Output
Question 5
Write a program to interchange the value of two numbers without using the third variable.
a = a + b;
b = a - b;
a = a - b;
Output
Question 6
Output
Question 7
Write a program to calculate the tax for a taxable income of Rs. 4,10,000, if the tax rate is fixed at 3.2%.
Output
Question 8
Create a program that will generate a bill at McDonald's for four vegetable burgers (@ Rs 45 per
vegetable Burger) and three vegetable McPuffs (@ Rs 25 per vegetable McPuff). There is a special
Independence Day discount of Rs 50 on the final bill amount.
System.out.println("Discount = 50");
}
Output