Java Quiz on Module 1 & 2

Quiz
•
Computers
•
Professional Development
•
Hard
Manzoor Ahmed
Used 3+ times
FREE Resource
21 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Can we create an instance of Enum outside of Enum itself?
True
False
Enum is not a class type
None of the above
Answer explanation
No, instances of Enum cannot be created outside of Enum boundary, because Enum does not have a public constructor.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following Java code?
enum Season
{
WINTER, SPRING, SUMMER, FALL
};
System.out.println(Season.WINTER.ordinal());
0
1
2
3
Answer explanation
ordinal() method provides number to the variables defined in Enum.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
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
It runs successfully
EnumNotDefined Exception
Answer explanation
Enum types cannot extend class.
4.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
Consider the following code inside TestEnum.java file
enum Branches {
Delhi(2),Chennai(3),Mumbai(3),Bangalore(5);
private int noofOffice;
private Branches(int noofOffice){
this.noofOffice=noofOffice;
}
public int getNoofOffice(){
return noofOffice;
}
}
class TestEnum{
public static void main(String[] args) {
System.out.println(Branches.Bangalore.getNoofOffice());
}
}
What will happen after compilation of the code?
Compilation error "enum constructor cannot be private
Compilation error" Cannot have variables in enum"
Code will compile sucessfully
Compilation error "enum object should be created with new keyword"
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Choose a correct statement about Autoboxing in Java?
Boxing is the process of converting a primitive data to its equivalent Wrapper class type
Unboxing is the process of converting a Wrapper class object to its equivalent primitive data type
Autoboxing is the process of converting Primitive data type to Wrapper Object type automatically. Auto-Unboxing is the process of converting Wrapper type object to Primitive type automatically.
All the above
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which does autoboxing or unboxing in Java?
Compiler
Runtime
Third party tools
None
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Choose the right statement which does autoboxing in Java?
Integer temperature1 = 100;
int temperature2 = 101;
Integer temperature1 = 100; int temperature2 = 101;
All the above
Answer explanation
As part of auto-boxing, an INT number is converted to INTEGER object automatically.
Create a free account and access millions of resources
Similar Resources on Wayground
19 questions
Python Basic

Quiz
•
Professional Development
16 questions
Think it through

Quiz
•
University - Professi...
19 questions
JavaScript Básico

Quiz
•
Professional Development
25 questions
Iniciemos con Python

Quiz
•
Professional Development
21 questions
8. Primitive Data Types (Integer datatype)

Quiz
•
Professional Development
24 questions
Unit4_Servlets_Exam1

Quiz
•
Professional Development
20 questions
OOP Quiz for Level 2 Undergraduates

Quiz
•
Professional Development
20 questions
Pre-Assessment: Java Basics

Quiz
•
Professional Development
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
11 questions
All about me

Quiz
•
Professional Development
10 questions
How to Email your Teacher

Quiz
•
Professional Development
15 questions
Fun Random Trivia

Quiz
•
Professional Development
22 questions
Anne Bradstreet 1612-1672

Quiz
•
Professional Development
18 questions
Spanish Speaking Countries and Capitals

Quiz
•
KG - Professional Dev...
14 questions
Fall Trivia

Quiz
•
11th Grade - Professi...
15 questions
Disney Characters Quiz

Quiz
•
Professional Development
15 questions
Quiz to Highlight Q types & other great features in Wayground

Quiz
•
Professional Development