0% found this document useful (0 votes)
11 views2 pages

Set2

The document contains a series of programming questions and exercises related to concepts such as variable initialization, loops, operators, encapsulation, function overloading, and output generation in Java. It includes multiple-choice questions, coding tasks, and output prediction challenges. The questions cover fundamental programming principles and require knowledge of Java syntax and logic.

Uploaded by

tapaskumarmahato
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Set2

The document contains a series of programming questions and exercises related to concepts such as variable initialization, loops, operators, encapsulation, function overloading, and output generation in Java. It includes multiple-choice questions, coding tasks, and output prediction challenges. The questions cover fundamental programming principles and require knowledge of Java syntax and logic.

Uploaded by

tapaskumarmahato
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1. Assigning value to a variable during declaration is called _________?

a. Declaration b. Assignment c. Initialisation d. None of these

2. The loop: for(i=1;i>100;i--) will execute for:


a. 1 time b. 0 times c. 2 times d. 3 times

3. Two arithmetic expressions can be compared with if statement, using:


a. Arithmetic Operator b. Ternary Operator c. Logical Operator d. Relational Operator

4. The loop while(i--<=100); where i is initialised with 99 will iterate for :


a. 1 time b. 2 times c. 3 times d. infinite times

5. The operator that gives true if all inputs are true:


a. && b. || c. ! d. both a and b.

6. Which among the following best describes the encapsulation?


a. It is a way of combining various data members into a single unit
b. It is a way of combining various member functions into a single unit
c. It is a way of combining various data member functions and member functions into a single unit
which can operate on any data
d. It is a way of combining various data member functions and member functions that operate on
those data members into a single unit

7. Function overloading is an approach of which principle of OOPs?


a. Inheritance
b. Encapsulation
c. Abstraction
d. Polymorphism

8. How many times will “Hello” be print.

int count = 0;

do{

System.out.println(“Hello”);

Count++;

}while(count<5);

a. 3
b. 4
c. 5
d. 6
9. What is the output of the following?
a. System.out.println( “four :” +4+2 );
b. System.out.println( “four:” +(2+2) );

10. Give the output of the following :


i. Math.floor(-4.7)
ii. Math.ceil(3.4) + Math.pow(2,3)

11. Rewrite the given do-while loop by using for loop:


int m=51,p=0,i=1;
do{
if(m % i==0)
p+=2;
i++;
}while(i<=m);
System.out.println(p);

12. Write a nested for loop to print the following:


1
2 4
8 16 32
64 128 256 512

13. Find output:


Int a,b;
for(a=6,b=4;a<=4;a=a+4)
{
If(a%b==0)
Break;
}
System.out.println(a);

14. WAP to enter any 50 numbers and check whether they are divisible by 5 or not. If divisible then
perform the following tasks.
a. Display all the numbers ending with the digit 5
b. Count those numbers ending with 0(zero)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy