Core Java Unit 1: Introduction to Java
Easy Level Questions (5 Marks
Each)
(Bloom’s Taxonomy:
Remembering, Understanding)
1.
What is Java? Briefly
describe its origin and list two key reasons for its widespread adoption.
2.
List any three prominent
features or "buzzwords" of Java (e.g., platform independence,
object-oriented, secure). Briefly explain one of them.
3.
Name any two commonly
used Integrated Development Environments for Java programming. Discuss one
benefit of using an IDE over a text editor for writing Java code.
4.
Differentiate between
single-line (//)
and multi-line (/* ... */) comments in Java with an example of each. When would you
use one over the other?
5.
List and briefly
describe any five of the eight primitive data types available in Java,
mentioning their typical use cases.
6.
Define a "final
variable" in Java. Explain with an example why a final variable’s value cannot be changed after its initial
assignment.
Moderate Level Questions (5
Marks Each)
(Bloom’s Taxonomy:
Understanding, Applying, Analyzing)
8.
Explain in detail how
Java achieves platform independence, commonly referred to as "Write Once,
Run Anywhere." Discuss the role of the Java Virtual Machine in this
process.
9.
Provide a comprehensive
comparison of Java and C++ focusing on their differences in memory management,
pointer usage, and multiple inheritance.
10.
Illustrate the basic
structure of a simple Java program that prints "Welcome to Core
Java!" using public static void main(String[] args). Explain the role and significance of each keyword (public, static, void, main) in the main method signature.
11.
Write a complete Java
program to declare and initialize a
integer array
12.
Evaluate the role of
Java’s core features, such as its robust security model and automatic garbage
collection, in making it a preferred language for developing reliable and
secure applications. Provide concrete examples where these features are
critical.
13.
As a Java developer,
you encounter a program that occasionally throws an ArrayIndexOutOfBoundsException. Explain how you would effectively utilize a debugger
(like jdb in a command-line environment or a graphical debugger in
an IDE) to pinpoint the exact line of code causing this error and analyze the state of variables leading to it. Outline the
typical steps of a debugging session.
Difficult Level Questions (5
Marks Each)
(Bloom’s Taxonomy: Analyzing, Evaluating, Creating)
14.
"Java is purely
object-oriented, whereas C++ supports both procedural and object-oriented
paradigms." Evaluate this statement critically. Elaborate on the core
differences that justify this classification, providing specific features or
characteristics of both languages that support this distinction (e.g.,
primitive types vs. objects, global functions, inheritance models).
15.
Design and implement a
complete Java program that:
1.
Takes three integer
command-line arguments: principal, rate, and time_years.
2.
Declares a final variable COMPOUNDING_FREQUENCY initialized to 4 (for quarterly compounding).
3.
Calculates and prints
the interest
4.
Includes appropriate
comments and uses a 1D array to store the input arguments.
16.
Analyze the following Java code segments. For each, determine if
it will compile successfully. If not, identify the exact compilation error and
explain the underlying Java type conversion rules (implicit promotion, explicit
casting, or lack thereof) that lead to the error. Propose a correction for each
faulty segment.
// Scenario A: Byte Arithmeticbyteb1 = 70;
byteb2 = 80;
bytesumResult = b1 + b2; // Will this compile?
// Scenario B: Mixed Type CalculationintintVal = 10;
longlongVal = 50L;
floatfloatVal = 2.5f;
intfinalResult = intVal * longVal / floatVal; // Will this compile?
// Scenario C: Character to Integer Conversioncharch = 'K';
intcharSum = ch + 2; // What is the value of charSum? Will it compile?