JAVA
2.7K subscribers
73 photos
111 files
76 links
Download Telegram
class Program
{
public static void main(String[] args) {
try{
badMethod();
System.out.println("A");
}catch(RuntimeException ex){
System.out.println("B");
}catch(Exception ex1){
System.out.println("C");
}
finally{
System.out.println("D");
}
System.out.println("E");
}
public static void badMethod(){
throw new RuntimeException();
}
}

A) BD
B) BCD
C) BDE
D) BCDE
public class Program implements Runnable
{
private String holdA="This is";
private int[] holdB={1,2,3,4,5,6,7,8,9,10};
public static void main(String[] args) {
Program p=new Program();//Line6
(new Thread(p)).start();//Line7
(new Thread(p)).start();//Line8
}
public synchronized void run()//Line10{
for(int w=0;w<10;w++){
System.out.println(holdA+holdB[w]+".");
}
}
}
A) Compilation fails because of an error on Line 6
B)Compilation fails because of an error on Line 10
C)Compilation fails because of an error on Line 7 and 8
D) Compilation succeeds and the program print each value.
public class Program{ public static void main(String[] args) {try{ badMethod();System.out.println("A");}catch(Exception e){System.out.println("B");}finally{System.out.println("C");
}System.out.println("D");
}public static void badMethod(){} }
Anonymous Quiz
11%
AC
21%
BC
42%
ACD
26%
ABCD
A process that involves recognizing and focusing on the important characteristics of a situation or object is known as:
Anonymous Quiz
9%
Encapsulation
4%
Polymorphism
48%
Abstraction
9%
Inheritance
30%
Object persistence
In object-oriented programming, new classes can be defined by extending existing classes. This is an example of:
Anonymous Quiz
17%
Encapsulation
13%
Interface
8%
Composition
58%
Inheritance
4%
Aggregation
The wrapping up of data and functions into a single unit is called
Anonymous Quiz
78%
Encapsulation
4%
Abstraction
15%
Data Hiding
0%
Polymorphism
4%
Message passing.
Given a class named student, which of the following is a valid constructor declaration for the class?
Anonymous Quiz
42%
Student (student s) { }
15%
Student student ( ) { }
19%
Private final student ( ) { }
12%
Void student ( ) { }
12%
Static void student(){ }
The concept of multiple inheritances is implemented in Java by
I. Extending two or more classes.
II. Extending one class and implementing one or more interfaces. III. Implementing two or more interfaces
Anonymous Quiz
11%
Only (II)
26%
(I) and (II)
42%
(II) and (III)
16%
Only (I)
5%
Only (III)
What is the error in the following class definitions?

Abstract class xy { abstract sum (int x, int y) { } }
Anonymous Quiz
25%
Class header is not defined properly
25%
Constructor is not defined
33%
Method is not defined properly
0%
Method is defined properly
17%
No error
👍1
Which of these field declarations are legal within the body of an interface?
Anonymous Quiz
29%
Private final static int answer = 42
25%
public static int answer=42
17%
final static answer =42
17%
int answer
13%
No error
👍1
A method within a class is only accessible by classes that are defined within the same package as the class of the method. Which one of the following is used to enforce such restriction
Anonymous Quiz
25%
Declare the method with the keyword public
25%
Declare the method with the keyword private
25%
Declare the method with the keyword protected
25%
Do not declare the method with any accessibility modifiers
0%
Declare the method with the keyword public and private
Basic Java language functions are stored in which of the following java package?
Anonymous Quiz
54%
java.lang
18%
java.util
4%
java.awt
Which of the following is a member of the java.lang package?
Anonymous Quiz
14%
List
14%
Queue
36%
Math
25%
Stack
11%
Process