WorksheetsJAVA FUNDAMENTALS
Total questions: 20
Worksheet time: 34mins
Which of the following can be operands of arithmetic operators?
Numeric
Boolean
Both Numeric & Characters
Characters
What will be the output of the following Java program?
class Output {
public static void main(String args[]) {
int a = 1;
int b = 2;
int c;
int d;
c = ++b;
d = a++;
c++;
b++;
++a;
System.out.println(a + " " + b + " " + c); }
}
324
323
244
234
344
What will be the output of the following Java code?
class operators {
public static void main(String args[]) {
int x = 8;
System.out.println(++x * 3 + " " + x); }
24 8
27 9
24 9
27 8
What will be the output of the following Java code?
class Relational_operator {
public static void main(String args[]) {
int var1 = 5;
int var2 = 6;
System.out.print(var1 > var2); }
}
5
6
FALSE
TRUE
Which of these is not an Assignment Operator?
&=
|=
+=
<=
What will be the output of the following Java program?
class booloperators {
public static void main(String args[]) {
boolean var1 = true;
boolean var2 = false;
System.out.println((var1 & var2));
}
}
True
False
1
0
What will be the output of the following Java program?
public static void main(String args[]) {
char a = 65;
char b = 66;
char d = 68;
d--;
char c = --b;
a++;
System.out.println(b);
System.out.println(d);
System.out.println(b);
System.out.println(a);
}
}
A
C
A
B
B
A
B
A
B
A
C
A
A
D
A
B
What will be the output of the following Java program?
class squareroot {
public static void main(String args[]) {
double a, b;
a = 3.0;
b = 4.0;
double c = Math.sqrt(a * a + b * b);
System.out.println(c); } }
compilation error
25
7
5
Fill in the blanks
Every line of code that runs in java must be inside a ........
A ........... should always start with an uppercase first letter
(a)
Use the addition assignment operator to add the value 5 to the variable x.
int x = 10;
x (a) 5;
Java is used for :
Web applications
Database connection
Games
Desktop applications
Text Editing
Evaluate the following Java expression, if x=3, y=5, and z=10:
++z + y - y + z + x++
23
24
25
20
Java was originally named:
ISLAND
OAK
NEW C++
JOJO
Is Android based on Java?
TRUE
FALSE
Who invented Java?
Steve Jobs, Bill Gates, James Gosling, Trump, Smeagol ?
Where does a java program start executing instructions from:
class
source file
main method
object
Which is not a primitive data type in Java?
character
integer
boolean
class
What is the result of the following statement
int a=023;
int b=0x45;
System.out.println(a+b);
64
74
68
88
What is the result of the following statement
public static void main(String args[])
{
int var1 = 5;
int var2 = 6;
if ((var2 = 1) == var1)
System.out.print(var2);
else
System.out.print(++var2);
} }
3
5
6
2
Which output would be produced by
System.out.print("\\* This is not \n a comment *\\");
* This is not a comment *
\* This is not
a comment *\
\\* This is not
a comment *\\
\* This is not a comment *\
