Chapter -1
1.What are OOP's concept in java? Explain (3m,4m)
OOP’s concepts in Java are used to design programs using objects. The main
concepts are:
• Abstraction: Hiding details and showing only important features.
• Encapsulation: Wrapping data and methods into one unit.
• Inheritance: One class gets properties of another class.
• Polymorphism: One object can take many forms.
1. How polymorphism can be achieved in Java? (2m)
• Compile-time polymorphism: Method overloading
• Runtime polymorphism: Method overriding
2.What are the features of Java? (Or)Explain any 4? (4m) (2m)
Features of Java
1. Simple
• Java syntax is easy and similar to C++.
• Removes complex features like pointers and multiple inheritance.
2. Object-Oriented
• Uses classes, objects, inheritance, and polymorphism.
• Helps in code reusability and modular design.
3. Platform-Independent
• Follows WORA (Write Once, Run Anywhere).
• Uses bytecode that runs on JVM.
4. Secure
• No direct memory access using pointers.
• Provides security through bytecode verification.
5. Robust
• Uses garbage collection for memory management.
• Has strong exception handling.
6. Multithreading
• Supports multiple threads at a time.
• Improves performance and CPU usage.
, 7. Distributed
• Supports RMI for distributed applications.
• Can work with network-based systems.
8. High Performance
• Uses JIT compiler for faster execution.
• Efficient memory management.
9. Dynamic
• Supports runtime class loading.
• Can modify code at runtime.
10. Portable
• Runs on any system with JVM.
• No need to recompile for different OS.
3.What is an Array and write the syntax of initialization of an array in Java (2m)
An array is a collection of elements of the same data type stored in a continuous
memory location.
Syntax:
datatype[] arrayName = new datatype[size];
Example:
int arr[] = {10, 20, 30, 40, 50};
System.out.println(arr[0]); // 10
System.out.println(arr[2]); // 30
6. Types of array?
Types of Array
• One-Dimensional Array:
Stores elements using one index.
Example:
int arr[] = {1,2,3};
• Two-Dimensional Array:
Stores elements using two indices (rows and columns).
, Example:
int arr[][] = {{1,2},{3,4}};
• Multidimensional Array:
Stores elements using more than two indices.
Example:
int arr[][][] = {{{1,2},{3,4}}};
5. What is type casting and what are the different types of type conversion? (3m)
Type casting is the process of converting a value of one data type into another data type.
There are two types:
• Widening (implicit or automatic): Converting smaller data type to larger data
type automatically.
• Narrowing (explicit): Converting larger data type to smaller data type
Example:
class Test {
public static void main(String args[]) {
// Implicit Casting
int a = 10;
double b = a; // int → double
System.out.println(b); // 10.0
// Explicit Casting
double x = 10.5;
int y = (int)x; // double → int
System.out.println(y); // 10
}
}
7. Difference Between Primitive and Non-Primitive Data Types in Java Programming
(or)
1.What are OOP's concept in java? Explain (3m,4m)
OOP’s concepts in Java are used to design programs using objects. The main
concepts are:
• Abstraction: Hiding details and showing only important features.
• Encapsulation: Wrapping data and methods into one unit.
• Inheritance: One class gets properties of another class.
• Polymorphism: One object can take many forms.
1. How polymorphism can be achieved in Java? (2m)
• Compile-time polymorphism: Method overloading
• Runtime polymorphism: Method overriding
2.What are the features of Java? (Or)Explain any 4? (4m) (2m)
Features of Java
1. Simple
• Java syntax is easy and similar to C++.
• Removes complex features like pointers and multiple inheritance.
2. Object-Oriented
• Uses classes, objects, inheritance, and polymorphism.
• Helps in code reusability and modular design.
3. Platform-Independent
• Follows WORA (Write Once, Run Anywhere).
• Uses bytecode that runs on JVM.
4. Secure
• No direct memory access using pointers.
• Provides security through bytecode verification.
5. Robust
• Uses garbage collection for memory management.
• Has strong exception handling.
6. Multithreading
• Supports multiple threads at a time.
• Improves performance and CPU usage.
, 7. Distributed
• Supports RMI for distributed applications.
• Can work with network-based systems.
8. High Performance
• Uses JIT compiler for faster execution.
• Efficient memory management.
9. Dynamic
• Supports runtime class loading.
• Can modify code at runtime.
10. Portable
• Runs on any system with JVM.
• No need to recompile for different OS.
3.What is an Array and write the syntax of initialization of an array in Java (2m)
An array is a collection of elements of the same data type stored in a continuous
memory location.
Syntax:
datatype[] arrayName = new datatype[size];
Example:
int arr[] = {10, 20, 30, 40, 50};
System.out.println(arr[0]); // 10
System.out.println(arr[2]); // 30
6. Types of array?
Types of Array
• One-Dimensional Array:
Stores elements using one index.
Example:
int arr[] = {1,2,3};
• Two-Dimensional Array:
Stores elements using two indices (rows and columns).
, Example:
int arr[][] = {{1,2},{3,4}};
• Multidimensional Array:
Stores elements using more than two indices.
Example:
int arr[][][] = {{{1,2},{3,4}}};
5. What is type casting and what are the different types of type conversion? (3m)
Type casting is the process of converting a value of one data type into another data type.
There are two types:
• Widening (implicit or automatic): Converting smaller data type to larger data
type automatically.
• Narrowing (explicit): Converting larger data type to smaller data type
Example:
class Test {
public static void main(String args[]) {
// Implicit Casting
int a = 10;
double b = a; // int → double
System.out.println(b); // 10.0
// Explicit Casting
double x = 10.5;
int y = (int)x; // double → int
System.out.println(y); // 10
}
}
7. Difference Between Primitive and Non-Primitive Data Types in Java Programming
(or)