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

Quiz Question Set-2 (LBJ - Java Basics)

This document contains 10 quiz questions related to Java basics covering topics like: 1. Implicit and explicit type casting and loss of information during typecasting. 2. The difference between while and do-while loops. 3. Steps to resize an array without losing data. 4. What will happen if an integer variable is assigned a value outside its range. 5. How to write a for loop to display array elements in reverse order. 6. How to write a program to find first 10 prime numbers. 7. How to write a program to find even numbers between 1 to 50. 8. How to write a program based on a pseudocode to calculate

Uploaded by

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

Quiz Question Set-2 (LBJ - Java Basics)

This document contains 10 quiz questions related to Java basics covering topics like: 1. Implicit and explicit type casting and loss of information during typecasting. 2. The difference between while and do-while loops. 3. Steps to resize an array without losing data. 4. What will happen if an integer variable is assigned a value outside its range. 5. How to write a for loop to display array elements in reverse order. 6. How to write a program to find first 10 prime numbers. 7. How to write a program to find even numbers between 1 to 50. 8. How to write a program based on a pseudocode to calculate

Uploaded by

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

Quiz Question Set – 2

(LBJ Module 3– Java Basics)


Q.1) Write one example each on:
1. Implicit type casting
2. Explicit type casting
3. Loss of information while doing typecasting

Q.2) What is the difference between while and do…while loop in Java?

Q.3) Suppose we have an array of 5 elements, write the steps required to


resize the array in Java without loosing data

Q.4) The range of int datatype is between -2,147,483,648 and 2,147,483,647.


What will happen we if we try:
int x = 2,147,483,647 + 1;
System.out.println(x);
Will it be a compilation error or runtime error or will it display some value of x?

Q.5) Suppose we have created an array of 5 elements:


int[] arr = {10, 20, 30, 40, 50};
How will you write a for loop to display elements of the array in reverse order?

Q.6) Write a Java program to display the first 10 Prime numbers

Q.7) Write a Java program to find the even numbers between 1 to 50

Q.8) Write a Java program based on the pseudocode given below:


Step 1: Start
Step 2: Input grades of 4 courses M1, M2, M3 and M4,
Step 3: Calculate the average grade with formula "Grade=(M1+M2+M3+M4)/4"
Step 4: If the average grade is less than 60, print "FAIL", else print "PASS".
Step 5: End

Q.9) What will be the output of below Java program:


class TestApp {
int i[] = { 0 };

public static void main(String args[]) {


int i[] = { 1 };
alter(i);
System.ou t.println(i[0]);
}
public static void alter(int i[]) {
int j[] = { 2 };
i = j;
}
}

Q.10) What will be the output of below Java program:


public class TestApp {

public static void main(String[] args)


{
int index = 0;
boolean flag = true;
boolean reg1 = false;
boolean reg2 = false;
reg2 = (flag || ((index++) == 0));
reg2 = (reg1 || ((index += 2) > 0));

System.out.println(index);
}
}

You might also like