WorksheetsJava Fundamentals
Total questions: 89
Worksheet time: 43mins
What are the Type Conversions available in Java language?
A) Narrowing Type Conversion
B) Widening Type Conversion
A and B
D) None of the above
Which type of loop is best known for its boolean condition that controls entry to the loop?
A. do-while loop
B. for (traditional)
C. for-each
D. while
What will be the Output of the below code:
public class Demo{
public static void main(String[] arr){
}
public static void main(String arr){
}
}
a) Nothing
b) Error
C) Finite
d) Hii
char is 2 byte in storage?
True
False
Name the data type: '3'
int
char
String
None of the above
What data type would you use for storing the number of students in a class?
boolean
String
double
int
What is the output of the below Java code snippet?
char ch = 'A';//ASCII 65
int a = ch + 1;
ch = (char)a;
System.out.println(ch);
A) 66
B) A
C) B
D) 65
What is the output of the following code snippet?
int i = 0; for(i = 0 ; i < 5; i++)
{ }
System.out.println(i);
A. 5
B. 0
C. 4
D. Compilation Error
Function of the Scanner class to accept a float literal from the user is
nextInt( )
hasNext( )
next( )
nextFloat( )
Predict the value of k,
int k =10;
k=k+k++;
11
20
21
22
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 = 2 b = 3 c = 4 d = 1
a = 2 b = 3 c = 4 d = 1
Program does not compile.
a = 1 b = 2 c = 4 d = 2
Java was developed by
James gosling
John gosling
James frank
John frank
JDK stands for (a)
JVM stands for (a)
List out types of inheritance.
Single
Mulitple
Multi level
Hierarchy
List out oops concept.
Int data types represents _______ bits.
8
16
32
64
There are (a) types of data types.
(a) is a piece of memory that can contain a data value.
How many types of array?
1
2
3
4
Which component is used to compile,debug and execute the java programs ?
JRE
JIT
JDK
JVM
Which one of the following is not a java feature
Object-oriented
Use of pointers
Portable
Dynamic and Extensible
Which of these cannot be used for a variable name in java ?
Identifier & keyword
Identifier
Keyword
None of the mentioned
Which of the following is not an OOPS concept in java ?
Polymorphism
Inheritance
Compilation
Encapsulation
What is the numerical range of a char data tupe in java ?
0 to 256
-128 to 127
0 to 65535
0 to 32767
When does method overloading is determined?
At run time
At compile time
At coding time
At execution time
When overloading does not occur ?
More than one method with same name but different method signature and different number or type of parameters
More than one method with same name,same signature but different number of signature
More than one method with same name,same signature,same number of parameters but different type
More than one method with same , same number of parameters and type but different signature
When overloading does not occur ?
More than one method with same name but different method signature and different number or type of parameters
More than one method with same name,same signature but different number of signature
More than one method with same name,same signature,same number of parameters but different type
More than one method with same , same number of parameters and type but different signature
Which of these data types is used to store command line arguments?
a) Array
b) Stack
c) String
d) Integer
The given code will give following result
"Hello"
Hello
Compile-time error
Run-time error
What will be the output of the given code?
5 4
4 5
4 4
5 5
What will be the result of given programme?
Hello World!
Infinite loop
Compile-time error
Run-time error
In given code of Java, String args[] is used for ......
Passing arguments at compile time
Passing arguments at run time
Counting number of words
None of the given
____ keyword is used to make a class
new
Object
Class
class
Which of the following is a valid syntax for creating an object of a Box class?
Box obj = new Box();
Box obj = new Box;
obj = new Box();
new Box obj;
Output of following Java Program?
Derived::show() called
Base::show() called
Run time Error
Compilation Error
Output of following Java Program?
10
20
Compilation Error
Run Time Error
Output of following Java Program?
12
321
123
23
What will be the output of following program?
Base::show() called
Derived::show() called
Compiler Error
Runtime Error
Output of following Java program?
Base
Derived
Derived
Base
Base
Derived
Base
Derived
Base
Compiler Error
Predict the output of following Java Program
Compiler Error
Grandparent's Print()
Parent's Print()
Child's Print()
Child's Print()
Parent's Print()
Grandparent's Print()
Runtime Error
byte is 1 byte size in storage?
True
False
Long is 4 byte size in storage?
True
False
char is 2 byte in storage?
True
False
(=) sign means
equals and it is used for math problems in Java
assignment operator. It used to assign a value
Which one is used for remainder in Java?
/
%
+
*
int x = 3; in this case, which of the following statement is true?
x = x+1;
x++;
x += 1;
All of above
Which of the following is NOT safe and can result in a loss of data?
Narrowing primitive
Widening primitive
This data type returns true or false
String
boolean
char
int
Name the data type: 1.0
double
int
char
boolean
What data type would you use for storing the average test score in a class?
boolean
char
int
double
How would you declare a variable storing the tax rate?
int taxRate = 5.1;
taxRate = "5.1";
double taxRate = 5.1;
double taxRate = "5.1";
How would you declare a variable that tells you that someone passed a class?
boolean passed = 'true';
boolean passed = true;
passed = true;
String passed = "true";
Name the data type: "true"
boolean
char
String
double
Name the data type: '3'
int
char
String
None of the above
Name the data type: false
String
boolean
int
None of the above
What data type would you use for storing the number of students in a class?
boolean
String
double
int
Java programs are
Faster than others
Platform independent
Not reusable
Not sacable
Java has its origin in
COBOL
PERRL
Oak programming language
C language
Which one of the following is true for java
Java is object oriented and interpreted
Java is efficient and faster than C
Java is the choice of everyone
Java is not robust
The command javac is used to
Execute a Java program
Compile a Java program
Debug a Java program
Interpret a Java program
……………. are not machine instructions and therefore, Java interpreter generates machine code that can be directly executed by the machine that is running the Java program.
Compiled instruction
Compiled code
Byte code
Java mid code
Which of the following is not the Java primitive type
Byte
Float
Character
Long double
Which of the following is not mandatory in a variable declaration?
a semicolon
an identifier
an assignment
a data type
In Java variables, if first increment of the variable takes place and then the assignment occurs. This operation is also called…………………………
pre-increment
post-increment
incrementation
pre incrementation
The information written in java after // is ignored by the
Programmer
Interpreter
Compiler
All of the above
When the operators are having the same priority, they are evaluated from …………….. …………. in the order they appear in the expression.
right to left
left to right
Any of the order
Depends on the compilor
When a java program is compiled, it creates a
an obj file
an exe file
a .class file
a . sh file
The JDK is a superset of the JRE, and contains everything that is in the JRE, plus tools such
as the compilers and debuggers necessary for developing applets and applications.
True
False
Bootstrap class loader is responsible for
Loading the classes,
Programmer defined classes
Java's API classes
All the above
128
0
Compilation fails with an error at line 3
Compilation fails with an error at line 4
10,17,garbage value
10,15,58
Compiler Error
Runtime Error
10
9A
Error occured in line 3
None of the above
17
16
15
Error in line no. 5
What is the output for the given code segment?
128
0
12
4
i : 1
i : 1
i : 2
i : 1
i : 1
i:1
i:2
1,2,3,4,5
1,2,4,5
1,2,4,5,6
All are valid
