1/22
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What is the size of an integer variable?
Options:
16 bit
128 bit
32 bit
8 bit
64 bit
32 bit
Does garbage collection guarantee that a program will not run out of memory?
Options:
True
False
False
What is the output of the code snippet below? If there is no output, answer "no output". If there is an error, answer "error".
int i=0; boolean t=true; boolean f=false,b; b=(t & ((i++)==0)); b=(f & ((i+=2)>0)); System.out.print(i);
3 (due to bit-wise operators)
Which of the following lines of code will compile without error? (Choose all that apply)
Options:
boolean i=true, j=false; if(i && j) System.out.println("OK");
boolean b=true; if(b) System.out.println("So true");
int i=2, j=2; if(i==1 | j==2) System.out.println("OK");
int i=0; if(i) System.out.println("Hello");
a, b, & c
Which of the following are legal identifiers? (Choose all that apply)
Options:
_whatavariable
variable2
2variable
$2
#myvar
for
___
if
_whatavariable, variable2, $2, ___
What is the output of the code snippet below? If there is no output, answer "no output". If there is an error, answer "error".
boolean x=true; int a; if(x) a = x ? 1 : 2; else a = x ? 3: 4; System.out.print(a);
1
What is an applet?
Options:
It is a Java program that runs in a Web browser
It is a tool
It is a run time environment
It is a stand-alone Java program
It is an IDE
It is a Java program that runs in a Web browser
It is possible to force garbage collection in Java.
Options:
True
False
False
Primitive variables are stored on stack.
Options:
True
False
True
What is the output of the code snippet below? If there is no output, answer "no output". If there is an error, answer "error".
boolean a[] = new boolean[10]; for(int i=5; i<=10 ; i++) System.out.print(a[i]);
error
When an object is passed as a parameter to a method, a copy of the object is created.
Options:
True
False
False
Local variables are automatically assigned a default value if not explicitly initialized.
Options:
True
False
False
What is the output of the code snippet below? If there is no output, answer "no output". If there is an error, answer "error".
int i=0; boolean t=true; boolean f=false, b; b=(t && ((i++)==0)); b=(f && ((i+=2)>0)); System.out.print(i);
1 (skips evaluating 2nd b, due to false condition)
What is the output of the code snippet below? If there is no output, answer "no output". If there is an error, answer "error".
int i=5; if(i==5){ int j=10, j+=i; } System.out.println(j);
error, j is not initialized prior to if-condition. After traversing if-condition, j will not exist outside the if-condition, and the print function incurs an error.
Which of the following lines will compile without warning or error?
Options:
short s = 900000; char c = 10;
float f = 2.5; boolean b = "true";
short s = 900000; char c = 10;
What is the output of the code snippet below?
int temp=1, temp2=0, ans=0, num=5; for(int i=1; i<= num; i++){ ans = temp + temp2; temp = temp2; temp2 = ans; System.out.print(ans + " "); }
1 1 2 3 5
What is the output of the code snippet below? If there is no output, answer "no output". If there is an error, answer "error".
int i=1; switch(i) { default: System.out.println("default"); case 0: System.out.println("zero"); break; case 1: System.out.print("one"); case 2: System.out.print("two"); }
onetwo
A byte can be of what size
Options:
-128 to 127
(-2 power 8)-1 to 2 power 8 depends on the particular implementation of the Java Virtual Machine -255 to 256
-128 to 127
Which of the following are legal definitions of the main method that can be used to execute a class?
Options:
public static void Main(String[] args)
public static int main(String args[])
public static void main(string args[])
Public static void main(String args[])
public static void main(String args[])
public static void main(String *args)
static public void MAIN(String[] args)
public void main(String args)
public static void main(String args[])
What is the output of the code snippet below? If there is no output, answer "no output". If there is an error, answer "error".
int x=0, y=1, z; if(x) z=0; else z=1; if(y) z=2; else z=3; System.out.print(z);
error
It is possible to change the contents of a String object.
Options:
True
False
False
Which of the following is not a keyword in Java?
Options:
public
private
void
Boolean
static
Boolean
What will happen when you attempt to compile and run this code?
public class Main{ public static void main(String argv){ System.out.println("Hello world"); } }
Options:
The code will compile but will complain at run time that main is not correctly defined
The code will compile but will complain at run time that no constructor is defined
The compiler will complain that main is a reserved word and cannot be used for a class
The code will compile and when run will print out "Hello world"
The code will compile but will complain at run time that main is not correctly defi