You are on page 1of 1

Object-Oriented Programming, BS-CS(A) II, Quiz 1

Spring 2022
Maximum Marks: 2.5 Instructor: Dr. Sajid Khan
Name:______________ CMS ID:__________________ Date:23/03/2022

Marks distribution (1.5+0.5+0.5)

1. Write a program in Java that allow used to input as much numbers he/she wants. However, user is
required to enter “sum”, “mul” or “ave” to end the input stream. If user enters sum it should
display sum of all numbers entered. In case if user writes mul at the end, multiplication of
numbers should be displayed. In case if ave is provided at the end, average should be displayed.
In case if you don’t remember the names of functions, you can name write any

2. Predict the output of the following

class HelloWorld {
public static void main(String[] args) {
int a = 19, b = 20;
int c = a^b;
int d = c|b|255;
System.out.println("a&b=" + c +"\n c|b|255 = "+d);
}
}
3. Why was there a need for Java language? Define within three lines.

You might also like