Java Programming and Dynamic Webpage Design Important Questions | BCA 5th Semester CCSU
1. Java is a platform-independent: Justify.
Java is considered platform-independent because Java programs are compiled into bytecode, which can run on any machine with a Java Virtual Machine (JVM). The JVM acts as an intermediary, interpreting the bytecode for the host machine, making Java "write once, run anywhere" (WORA).
2. Difference between JSP and Servlet:
Aspect | JSP (JavaServer Pages) | Servlet |
---|---|---|
Nature | HTML with Java code | Pure Java code |
Ease of Use | Easier to write and maintain | More complex and verbose |
Compilation | Automatically compiled by the server | Needs manual compilation |
Usage | Used for presentation layer | Used for logic and processing |
3. Compare JDK, JRE, and JVM:
Component | Description |
---|---|
JDK (Java Development Kit) | Provides tools for developing Java applications, including JRE, compilers, and debuggers. |
JRE (Java Runtime Environment) | A subset of JDK for running Java programs; includes JVM and libraries but not compilers. |
JVM (Java Virtual Machine) | Executes Java bytecode and provides platform independence. |
4. What do you mean by a package in Java?
A package in Java is a namespace that organizes classes and interfaces. It helps avoid naming conflicts and makes it easier to locate and use the classes.
5. Explain Servlet.
A servlet is a Java class used to handle HTTP requests and generate dynamic web content. It runs on a web server and extends the capabilities of servers.
6. What is Applet Viewer? Explain.
The Applet Viewer is a command-line utility that lets you run and test Java applets without a web browser.
7. Explain the main components of JSP.
- Directives: Control the JSP page's structure and processing.
- Scriptlets: Embed Java code within the JSP.
- Expressions: Output dynamic content.
- Custom tags and libraries: Simplify tasks.
8. What do you mean by a package in Java?
(Same as Question 4)
9. Difference between JDBC and ODBC:
Aspect | JDBC (Java Database Connectivity) | ODBC (Open Database Connectivity) |
---|---|---|
Language | Java-specific | Language-independent |
Platform | Platform-independent | Platform-dependent |
Security | More secure | Less secure |
10. Difference between a function and a method:
Aspect | Function | Method |
---|---|---|
Definition | Independent block of code | Function tied to an object |
Context | Does not belong to an object | Belongs to an object |
11. Packages in Java: Creation and Example
Packages are created using the package
keyword. Example:
package myPackage;
public class MyClass {
public void display() {
System.out.println("This is a package example.");
}
}
12. What is an Exception? Handling and Difference between throw
and throws
:
- Exception: An event that disrupts the normal flow of a program.
- Handling: Using
try
,catch
,finally
. - Throw vs. Throws:
throw
: Used to explicitly throw an exception.throws
: Declares exceptions in the method signature.
13. Various AWT Controls:
- Button
- Checkbox
- TextField
- Label
Example: The
Button
control allows users to perform actions by clicking.
14. Features of Java Programming Language:
- Platform-independent
- Object-oriented
- Secure
- Multithreaded
- Robust
15. Inheritance in Java and Its Types:
Inheritance allows a class to inherit properties from another. Types:
- Single
- Multilevel
- Hierarchical
- Hybrid
16. Explain Socket and Its Types:
A socket is an endpoint for communication between two machines. Types:
- Stream socket
- Datagram socket
Example:
Socket
andServerSocket
classes in Java.
17. Explain the Following:
- Multi-threading: Executing multiple threads concurrently.
- Encapsulation: Wrapping data and code into a single unit.
18. Explain the Following:
- Super and Final:
super
calls the parent class;final
restricts modifications. - CSS: Styles web pages.
- RMI: Enables remote method invocation.
19. Layout Manager in Java and Its Types:
- Types: BorderLayout, GridLayout, FlowLayout, etc. Example:
Frame f = new Frame();
f.setLayout(new FlowLayout());
20. Explain the Following:
- HTML Tags: Define web content structure (e.g.,
<div>
,<p>
). - HTTP: Protocol for web communication.
- Networking: Facilitates communication between devices.