WorksheetsJava Quiz1 @ VCE (CSE (AI&ML))
Total questions: 15
Worksheet time: 8mins
Where an object of a class get stored?
Heap
Stack
Memory
Disk
Garbage collection in Java is
Unused package in a program automatically gets deleted.
Java deletes all unused java files on the system.
Memory occupied by objects with no reference is automatically reclaimed for deletion.
The JVM cleans output of Java program.
Which is the important Concept in the following in Java?
Compiler
JVM
Interpreter
All the Above
______ binds the data and functions into single unit.
Function
Package
Class
All the Above
Who invented Java?
Berkly
James Gosling
Dr. E.F.Codd
Sergy Brin
_________________ is a collection of elements used to store the same type of data.
Array
Class
List
Switch
int [] nums = {2, 3, 5, 8, 9, 11};
How would you access the fourth element in nums?
nums[4]
nums(3)
nums[3]
nums[4]
Index values of an array range from ______________.
1 to length
0 to length-1
0 to length
0 to length+1
Name the data type: "true"
char
String
boolean
Array
What data type would you use for storing the average test score in a class?
int
double
boolan
String
How would you declare a variable that tells you that someone passed a class?
boolean passed='true';
boolean passed="true";
boolean passed=true;
String passed="true";
a=1;
a++;
1
2
3
4
Which statement(s) are equivalent to i = i + 1?
i+=1
i++
i-=1
i--
Find the output for the following.
public class IncDec
{
public static void main(String s[])
{
int a = 1;
int b = 2;
int c;
int d;
c = ++b;
d = a++;
c++;
System.out.println("a = " + a);
System.out.print("b = " + b);
System.out.println("c = " + c);
System.out.print("d = " + d);
}
}
a = 1 b = 2 c = 4 d = 2
Program does not compile.
a = 2 b = 3 c = 4 d = 1
a = 2 b = 3 c = 4 d = 1
Which feature of OOP allows us to hide few details and gives exposure to some of the details
Polymorphism
Encapsulation
Abstraction
Inheritance
