
StreamApiExceptionbasics
Authored by khushbu mehta
Other, Architecture
KG
Used 8+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
5 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
class Arr {
public static void main (String args[]) {
try{
throw new RuntimeException();
}catch(RuntimeException e) {
try{
System.out.println("Hello");
e.printStackTrace();
}
catch(Exception x) {
System.out.println(x);
}
}
}
}
It will print Hello
It will Print Hello and RuntimeException
program will not compile
It will throw run time exception
2.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
Compilation fails.
The code executes and prints "running".
The code executes and prints "runningrunningrunning".
An exception is thrown at runtime.
3.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
class Rose {
static int j;
public int arr() {
int y[] = { 5 , 7, 8 , 6};
j = y[2]; return j;
}
public static void main (String args[]) {
Rose r=new Rose();
int x = r.arr( );
System.out.println(x);
}
}
}
What would be the output when Sam compile and execute this program?
7
8
ccompilation error
exception thrown
4.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
public class Rose{
public static void main(String[] args) {
char x = 'a';
switch(x){
case 66: System.out.println( "B" +"");break;
case 72: System.out.println( "H"+ "");break;
case 97: System.out.println("A"+ "");break;
case 89: System.out.println( "Y" + "");break;
default: System.out.println( "default");break;
}
}]
program will not compile
Program will display a Y
Program will display A
Program will display a Y default
5.
MULTIPLE CHOICE QUESTION
1 min • 5 pts
import java.util.*;
class Rose {
public static void main (String args[]) {
ArrayList <Integer> arraylist = new ArrayList<Integer>();
arraylist.add(0);
arraylist.add(2);
arraylist.add(3);
arraylist.add(4);
int y= arraylist.size();
switch(y) {
case 0: System.out.println(0);break;
case 2: System.out.println(2);break;
case 4: System.out.println(4);break;
case 5: System.out.println(5);break;
default: System.out.println("Default");
}
}
4
Compilation error
2
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?