0% found this document useful (0 votes)
5 views2 pages

Java 10 Mark Answers

The document covers various Java programming concepts including multiple inheritance using interfaces, a restaurant menu management system utilizing abstract classes and interfaces, a thread-safe ticket booking system, managing student records with ArrayList, a JavaFX form application, and a Swing login form with validation. Each section provides code examples demonstrating the implementation of these concepts. Overall, it serves as a practical guide for using Java features effectively.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Java 10 Mark Answers

The document covers various Java programming concepts including multiple inheritance using interfaces, a restaurant menu management system utilizing abstract classes and interfaces, a thread-safe ticket booking system, managing student records with ArrayList, a JavaFX form application, and a Swing login form with validation. Each section provides code examples demonstrating the implementation of these concepts. Overall, it serves as a practical guide for using Java features effectively.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Q4(c): Multiple Inheritance using Interfaces

Java supports multiple inheritance through interfaces. A class can implement more than one
interface.

interface Student {
void study();
}

interface Athlete {
void play();
}

class StudentAthlete implements Student, Athlete {


public void study() {
[Link]("Student is studying.");
}
public void play() {
[Link]("Athlete is playing.");
}
public static void main(String[] args) {
StudentAthlete sa = new StudentAthlete();
[Link]();
[Link]();
}
}

Q5(c): Restaurant Menu Management System

This program uses abstract class and interface to manage menu operations.

import [Link];

interface MenuOperations {
void addItem(String item);
void removeItem(String item);
void displayMenu();
}

abstract class Restaurant {


ArrayList<String> menu = new ArrayList<>();
}

class MenuManager extends Restaurant implements MenuOperations {


public void addItem(String item) {
[Link](item);
}
public void removeItem(String item) {
[Link](item);
}
public void displayMenu() {
for(String item : menu) {
[Link](item);
}
}
}

Q6(c): Ticket Booking System using Threads

Synchronization ensures thread-safe ticket booking.

class TicketBooking {
int tickets = 10;
synchronized void bookTicket(int qty) {
if(tickets >= qty) {
tickets -= qty;
[Link]("Booked " + qty);
} else {
[Link]("Not enough tickets");
}
}
}

Q7(c): Student Records using Collections

ArrayList is used to store and manage student records.

import [Link].*;

class Student {
int id;
String name;
int marks;
Student(int id, String name, int marks) {
[Link] = id;
[Link] = name;
[Link] = marks;
}
}

class Main {
public static void main(String[] args) {
List<Student> list = new ArrayList<>();
[Link](new Student(1,"Ravi",85));
for(Student s : list) {
[Link]([Link]);
}
}
}

Q8(c): JavaFX Form Application

JavaFX form that displays user input in a new window.

Button submit = new Button("Submit");


[Link](e -> {
[Link]("Form Submitted");
});

Q9(c): Swing Login Form

Swing-based login form with username and password validation.

if([Link]("admin") && [Link]("1234")) {


[Link](frame,"Welcome");
}

You might also like