stud
bud
Sign up
Log in
Home
Library
Explore
SAT
More
Lec7 Flashcards | StudBud
Explore
/
Lec7
Lec7
17 terms
·
StudBud Administration
·
11 plays
Test your knowledge on programming concepts with questions about code results and upcasting
Flashcards
17 cards
F
Practice quiz
P
Host live
L
Questions
17
Answers
1
What is printed?
null
Animal
Dog
Compilation error
2
Output of int[] arr = {1, 2, 3}; System.out.println(arr[1]);
2
3
IndexOutOfBounds
1
3
What is true about abstract classes in Java?
They must contain only abstract methods
They may have both abstract and concrete methods
They must implement interfaces
They can be instantiated
4
Can we print Animal from a Dog object?
False
True
5
Which operator is used for logical AND in Java?
&
&&
||
and
6
What is the result of the following code
7.0
7
52.0
Compilation error
7
Identify the correct declaration.
abstract class Car { abstract void start() {} }
interface abstract Car {}
class abstract Car {}
abstract class Car { abstract void start(); }
8
What is the result of the following code?
2.5
2
Compilation error
2.0
9
Which keyword is used to inherit a class in Java?
super
implement
extends
inherits
10
What will be printed?
012
123
0123
Loop runs infinitely
11
Output String s = null; System.out.println(s.length());
null
0
NullPointerException
Compilation error
12
Which loop guarantees at least one execution?
foreach
for
while
do-while
13
Which access modifier supports encapsulation the most?
private
public
protected
final
14
This is
declaration of i
Loop
condition
iteration over array
15
What is the length of this array? int[] arr = new int[5];
0
4
5
null
16
Which of the following lines
does not
demonstrate valid upcasting (widening conversion)?
int a = (int) 5.5;
double d = (double) 5;
long l = 100;
float f = 10L;
17
Which concept is represented?
downcasting
upcasting
primitive data types
encapsulation