Shri Ambabai Talim sanstha’s
Sanjay Bhokare Group Of Institutes, Miraj
Faculty Of Engineering
Continuous Assessment - I Semester Examination
Programme: B. Tech Branch: Electronic and computer Science Engineering
Course Code: BTECOE504C Course Name: Programming in Java
Semester: V Academic Year: 2025-2026
Date: 16-09-2025 Max Marks: 10
Time: 1:00PM – 2:00PM Student PRN No.:
Instructions:
1. Assume suitable data, if necessary. 2. Neat Diagrams must be drawn wherever necessary.
3. Writing on question paper is not allowed. 4. Mobile and programmable calculators are
not allowed.
5. Attempt all questions. 6. Figures to the right indicate the full marks.
7. Write PRN Number on Question Paper. 8. Exchange / Sharing of stationery, calculator not
allowed.
Q1 Solve Any TWO of the Following Questions (3 x 2 Marks=6 Level Marks CO PO PSO
Marks)
CO
a. 3M
Differences between C,C++,java. 1
Ans:
C Language
1. Developed by Dennis Ritchie in 1972 at AT&T Bell Labs.
2. It is a procedural (structured) programming language.
3. Focuses on functions and procedures, not objects.
4. Platform dependent – compiled code runs only on one
operating system.
5. Memory management is manual using malloc() and
free().
6. Pointers are fully supported and frequently used.
7. Object-oriented features like classes, inheritance, and
polymorphism are not supported.
8. Operator overloading and exception handling are not
available.
9. Uses header files (#include) and printf()/scanf() for
input/output.
10. Execution is fast and suitable for system-level
programming (like OS, drivers, embedded systems).
C++ Language
1. Developed by Bjarne Stroustrup in 1983 at AT&T Bell
Labs.
2. It is a multi-paradigm language – supports both
procedural and object-oriented programming.
3. Introduces classes, objects, inheritance, polymorphism,
and encapsulation.
4. Platform dependent – compiled directly to machine
code.
5. Memory management is manual, but uses new and
delete operators.
6. Supports pointers, operator overloading, and function
overloading.
7. Has exception handling using try, catch, and throw.
8. Uses header files and cin/cout (from iostream) for
input/output.
9. Faster than Java, but slightly slower than C due to
added OOP features.
10. Commonly used for game development, system
software, and large-scale applications.
Java Language
1. Developed by James Gosling in 1995 at Sun
Microsystems.
2. It is a pure object-oriented programming language
(with some procedural features).
3. Code is compiled to bytecode and executed on the Java
Virtual Machine (JVM).
4. Platform independent – “Write once, run anywhere”.
5. Automatic memory management using Garbage
Collector.
6. Pointers are not supported (restricted for security
reasons).
7. Operator overloading is not supported.
8. Exception handling is powerful – uses try, catch, finally,
and throw.
9. Uses packages instead of header files and
[Link]() for output.
10. Slower than C/C++ because it runs on JVM, but highly
portable, secure, and reliable.
11. Widely used in web development, mobile apps
(Android), and enterprise systems.
CO
b. 3M
What is JVM (Java Virtual Machine)? Explain its role in Java 1
program execution ?
Ans:
Definition:
The Java Virtual Machine (JVM) is a virtual (software-based)
engine that provides a runtime environment to execute Java
programs. It is part of the Java Runtime Environment (JRE) and
is responsible for converting Java bytecode into machine code
that can be executed by the computer’s hardware.
In simple terms, JVM acts as an interpreter between the
compiled Java code and the operating system.
Role of JVM in Java Program Execution
The JVM plays a crucial role in the execution process of every
Java program. The main steps are explained below:
1. Compilation (Java → Bytecode):
o When you write a Java program (.java file) and
compile it using the Java compiler (javac), it is
converted into an intermediate form called
bytecode (.class file).
o This bytecode is platform-independent and can
run on any system that has a JVM.
2. Class Loader:
o The class loader in the JVM loads the
compiled .class files (bytecode) into memory
when the program is executed.
o It handles loading, linking, and initializing of
classes.
3. Bytecode Verifier:
o Before execution, the bytecode verifier checks
the code for security violations or illegal code
that might corrupt the system (e.g., accessing
unauthorized memory).
4. Interpreter / Just-In-Time (JIT) Compiler:
o The interpreter reads the bytecode instructions
and executes them one by one.
o The JIT compiler improves performance by
converting frequently used bytecode into native
machine code directly.
5. Execution Engine:
o This component actually executes the native
code on the underlying hardware.
o It manages memory, CPU instructions, and
system resources during execution.
6. Memory Management (Garbage Collection):
o The JVM manages memory automatically.
o The Garbage Collector (GC) frees up memory by
removing objects that are no longer in use,
improving efficiency.
CO
c. Explain the logical operators in Java with the help of examples ? 3M
1
Definition:
Logical operators in Java are used to combine two or more
conditions (boolean expressions) and return a true or false
result based on their logic.
They are mainly used in decision-making statements like if,
while, and for
Types of Logical Operators
1) Logical AND (&&)
2) Logical OR (||)
Detailed Explanation with Examples
1. Logical AND ( && )
Syntax: condition1 && condition2
Returns true only if both conditions are true.
Example:
int a = 10, b = 20, c = 30;
if (a < b && b < c) {
[Link]("Both conditions are true");
} else {
[Link]("At least one condition is false");
}
Output:
Both conditions are true
2. Logical OR ( || )
Syntax: condition1 || condition2
Returns true if any one of the conditions is true.
Example:
int x = 5, y = 10;
if (x > 0 || y < 0) {
[Link]("At least one condition is true");
} else {
[Link]("Both conditions are false");
}
Output:
At least one condition is true
Q2 Multiple Choice Questions (4 x 1 = 4 Marks)
CO
a. What is the default value of an int variable in Java? 2
A. 0 B. null C. undefined D. 1
Ans: A.0
4M
Which operator is used to compare two values in Java?
CO
b. A.= B. == C. === D. := 2
Ans: B. ==
CO
c. Which keyword is used to define a constant in Java? 2
A. const B. final C. static D. constant
Ans: B. final
Which component is responsible for running Java bytecode?
d.
A. JDK B. JRE C. JVM D. Compiler
Ans: C. JVM
1/1