Java Fundamental v2
How many arguments can be passed to main()?
public static void main(String args[]) {
//...
}
1000
Infinite
System dependant
1
None of the Above
How do you insert comments in Java code?
-- This is a comment
# This is a comment
// This is a comment
/* This is a comment
What will be the output of the following Java program ?
Command line execution is done as – "java Output This is a command Line"
class Output {
public static void main(String args[])
{
System.out.print(args[0]);
}
}
Java
Output
This
Is
This is a command Line
What will be the output of the following Java program ?
Command line execution is done as – "java Output command Line 10 A b 4 N"
class Output {
public static void main(String args[])
{
System.out.print((int)args[2] * 2);
}
}
Java
10
20
Throw error
None of the Above
Which of the following is a superclass of every class in Java?
String
Object class
Abstract class
ArrayList
What will be the return type of a method that does not return any value?
Double
Void
Int
None of the above
Which of these is the correct way of inheriting class A by class B?
Class B extends class A {}
Class B inherits class A {}
Class B + class A {}
Class B extends A {}
Which of these access modifiers can be used for an interface?
Private
Public
Protected
All of the above
Which of these operators can be used to concatenate two or more String objects ?
||
&
&&
+
What is the value returned by fun ction compareTo() if the invoking string is less than the string compared ?
Value greater than zero
Zero
Value less than zero
None of the above
What will this code snippet print?
double decimal = 50.55;
int integer = (int)decimal;
System.out.println(integer/3);
16.67
16
17
16.00
What is the output of this code snippet?
int I = 34.0;
int j = 7;
int k = I % j;
System.out.println("k = " + k );
K = 4
K = 6
K = 0
Program doesn't compile
Which of these method of Thread class is used to suspend a thread for a period of time ?
Stop()
Suspend()
Terminate()
Sleep()
Suppose a class has public visibility. In this class we define a protected method. Which of the following statements is correct ?
In a class, you cannot declare methods with a lower visibility than the visibility of the class in which it is defined.
From within protected methods you do not have access to public methods.
This method is only accessible from inside the class itself and from inside all subclasses.
This method is accessible from within the class itself and from within all classes defined in the same package as the class itself.
When you pass an array to a method, the method receives
The length of the array
The reference of the array
A copy of the first element
A copy of the array
Array indexes start with:
0
1
01
00
What is the output of the following code snippet ?
void testArray(){
int arrayVariable [] = new int[10];
for (int I = 0; I < 10; ++i)
{
arrayVariable[i] = I;
System.out.print(arrayVariable[i] + " ");
i++;
}
}
Which of the following is a correct way to declare an array in Java ?
Int[] arr1 = new int[3];
Int arr1[] = new int[3];
Both of the above
None of the above
Which of these can be used to differentiate two or more methods having same name ?
Return type of method
Parameters data type
Number of parameters
All of the above
Which of these clause will be executed even if no exceptions are found ?
Catch
Throw
Finally
None of the Above
Which of these types cannot be used to initiate a generic type ?
Collections
Primitive Types
Float class
Integer class
Which polymorphism behavior do you see in class below?
class Paint {
// all methods have same name
public void Color(int x) {
}
public void Color(int x, int y) {
}
public void Color(int x, int y, int z) {
}
}
Method overloading
Constructor overloading
Method overriding
None of the above
public abstract class Book {
private String name;
private String author;
private double price;
public Book(String name, String author, double price) {
this.name = name;
this.author = author;
this.price = price;
}
public Book(Book source) {
this.name = source.name;
this.author = source.author;
this.price = source.price;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getAuthor() {
return this.author;
}
public void setAuthor(String author) {
this.author = author;
}
public double getPrice() {
return this.price;
}
public void setPrice(double price) {
this.price = price;
}
}
public class NonFiction extends Book {
private String topic;
public NonFiction(String name, String author, double price, String topic) {
super(name, author, price);
this.topic = topic;
}
public NonFiction(NonFiction source) {
super(source);
this.topic = source.topic;
}
public String getTopic() {
return this.topic;
}
public void setTopic(String topic) {
this.topic = topic;
}
}
Will this code compile?
Book nonfic = new NonFiction("Silent Spring", "Rachel Carson", 20, "Environmental Science");
nonfic.getTopic();
Yes
No
Based on the classes defined in Q29, will this compile?
Book book = new Book("Silent Spring", "Rachel Carson", 20);
Yes
No
What will be the output of the following Java code snippet?
class A
{
}
enum Enums extends A
{
ABC, BCD, CDE, DEF;
}
Runtime Error
Compilation Error
Compile & runs successfully
EnumNotDefined Exception
What will be the output of the following Java code?
class bool_operator {
public static void main(String args[]) {
boolean a = true;
boolean b = !true;
boolean c = a | b;
boolean d = a & b;
boolean e = d ? b : c;
System.out.println(d + " " + e);
}
}
False false
True true
True false
False true
Compilation error
What is the output for this code snippet?
int[] numbers = new int[] {4, 5, 6};
Arrays.stream(numbers)
.filter((number) -> number < 6)
.map((number) -> number % 2)
.forEach((number) -> System.out.println(number));
0
1
1
0
1
1
0
0
None of the above
What is the output of the following code?
class HelloWorld {
public static void main(String args[]) {
try {
int a = 0;
int b = 5;
int c = a / b;
System.out.print("Hello ");
} catch (Exception e) {
System.out.print("World ");
} finally {
System.out.print("Again");
}
}
}
Hello World Again
World
Hello Again
World Again
Again
Hello
Which of the following is not an object ?
String a = "1234"
Double a = 2
Scanner scan = new Scanner(System.in)
Int[] a = new int[] {4, 5, 6};
All of the above
Which statement is used to stop a loop?
Stop
Exit
Return
Break
All of the Above
Which keyword is used to return a value inside a method
Void
Return
Get
Break
None of the Above
Which method can be used to find the highest value of j & k?
Math.max(j,k)
Math.maximum(j,k)
Math.largest(j,k)
Math.maxNum(j,k)
{"name":"Java Fundamental v2", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Java Fundamental V2 quiz for Simplr Logic Sdn Bhd","img":"https://www.poll-maker.com/3012/images/ogquiz.png?sz=1200-00000000001000005300"}
More Quizzes
100
Juicy Quiz
1168
Do you have any recommendations in new papers today?
100
Hard Booper Quiz
1166
Free Newborn Assessment: Test Your Skills
201029214
Ultimate Dodgers Trivia: Can You Ace Our LA Dodgers?
201023929
Free Financial Statement Spreading
201021675
Free Online Club Training Knowledge Test
201026124
Challenge Yourself: Medical Terminology True or False
201026124
Which Ninjago Are You? Take Our Fun Now
201023929
What Is the Simple Predicate? Free Subjects & Predicates
201028896
Physical Geology
15829876