NEW
Font size
WorksheetsJava Basics
Total questions: 12
Worksheet time: 5mins
Java Source Code is compiled into
.Obj
Source Code
Bytecode
.Exe
Single line comment starts with _________ in Java.
/**
//
/*
None of these
Java is case sensitive?
True
False
Depends On Complier
May be true or false
How to compile java code in command prompt?
javac filename.java
java filename.java
javac filename
java filename
What is true in Java?
For all class names the first letter should be in Upper Case.
All method names should start with a Lower Case letter.
Name of the program file should exactly match the class name.
All of the above
All Java components require names. Names used for classes, variables, and methods are called?
Variables
identifiers
Access Modifiers
Java Modifiers
What is JRE?
JRE is a java based GUI application.
JRE is an implementation of the Java Virtual Machine which executes Java programs.
JRE is an application development framework.
None of the above
Default, public , protected, private are?
Access Modifier
Non-access Modifiers
Both A and B
It's variable
What will be the output of the program?class PassA
{
public static void main(String [] args)
{
PassA p = new PassA();
p.start();
}
void start()
{
long [] a1 = {3,4,5};
long [] a2 = fix(a1);
System.out.print(a1[0] + a1[1] + a1[2] + " ");
System.out.println(a2[0] + a2[1] + a2[2]);
}
long [] fix(long [] a3)
{
a3[1] = 7;
return a3;
}
}
12 15
15 15
3 4 5 3 7 5
3 7 5 3 7 5
What will be the output of the program?
class PassS
{
public static void main(String [] args)
{
PassS p = new PassS();
p.start();
}
void start()
{
String s1 = "slip";
String s2 = fix(s1);
System.out.println(s1 + " " + s2);
}
String fix(String s1)
{
s1 = s1 + "stream";
System.out.print(s1 + " ");
return "stream";
}
}
slip stream
slipstream stream
stream slip stream
slipstream slip stream
What will be the output of the program?class Equals
{
public static void main(String [] args)
{
int x = 100;
double y = 100.1;
boolean b = (x = y); /* Line 7 */
System.out.println(b);
}
}
true
false
Compilation fails
An exception is thrown at runtime
What will be the output of the program?
class Test
{
public static void main(String [] args)
{
int x= 0;
int y= 0;
for (int z = 0; z < 5; z++)
{
if (( ++x > 2 ) && (++y > 2))
{
x++;
}
}
System.out.println(x + " " + y);
}
}
5 2
5 3
6 3
6 4
