
Explain the following question in detail how to solve using java
1. Define an abstract class called Travel [defined in package1] with few appropriate data members and methods for getting and displaying the same, create two subclasses called “InternationalTravel” and “NationalTravel” with new necessary data members respectively. Create at least three objects for both of the subclasses and just display the info in package2 based on your travel experience so far. Also create a method which scans the places which you would like to travel along with tentative year, in which you may travel and display that as well.
2. Create another program for the same scenario, in which Thread1 will scan the details and store about InternationTravel details in File1, Thread2 will deal with NationalTravel and store the info in File2. Thread3 will fetch both the details from the files and store in the collections named IT and NT respectively.
Note: Please solve the 2nd question only using the first question scenario
please please please answer as fast as you can today is my deadline
please answer the proper working code with a detailed output screenshot
first question java code
1Q Answer:
Travel.java:-
package Package1;
import java.util.*;
abstract class Travel {
String name,phn_no,address;
int age;
Scanner sc=new Scanner(System.in).useDelimiter("\n");
abstract public void getmethord();
abstract public void printmethord();
}
InternationalTravel.java:-
package Package1;
public class InternationalTravel extends Travel {
String passport_no;
int j;
String visit[]=new String[10];
@Override
public void getmethord()
{
System.out.print("Enter your name: ");
name=sc.nextLine();
System.out.print("Enter your Address: ");
address=sc.nextLine();
System.out.print("Enter your Contact Number: ");
phn_no=sc.next();
System.out.print("Enter your Passport Number: ");
passport_no=sc.next();
System.out.print("Enter your Age(in years): ");
age=sc.nextInt();
System.out.println("Enter the visited Places in World--");
System.out.println("Enter 'finish' when you entered all your visited places!!");
System.out.println();
while(true)
{
System.out.print("Enter "+(j+1)+" place you had already visited: ");
visit[j]=sc.next();
if(visit[j].equals("finish"))
break;
j++;
}
System.out.println();
}
@Override
public void printmethord()
{
System.out.println("Name: "+name);
System.out.println("Age(in years): "+age);
System.out.println("Contact Number: "+phn_no);
System.out.println("Address: "+address);
System.out.println("Passport Number: "+passport_no);
System.out.println("Visited Places--");
for(int i=0;i<j;i++)
{
System.out.print((i+1)+" visited place in world: "+visit[i]);
System.out.println();
}
System.out.println();
}
}
NationalTravel.java:-
package Package1;
public class NationalTravel extends Travel{
int j=0;
String visit[]=new String[15];
@Override
public void getmethord()
{
System.out.println("Enter the visited Places in India--");
System.out.println("Enter 'finish' when you entered all your visited places!!");
System.out.println();
while(true)
{
System.out.print("Enter "+(j+1)+" place you had already visited: ");
visit[j]=sc.next();
if(visit[j].equals("finish"))
break;
j++;
}
System.out.println();
}
@Override
public void printmethord()
{
System.out.println("Visited Places--");
for(int i=0;i<j;i++)
{
System.out.print((i+1)+" visited place in India: "+visit[i]);
System.out.println();
}
System.out.println();
}
}
DA_1Q_C2_19BDS0119:-
package Package2;
import Package1.InternationalTravel;
import Package1.NationalTravel;
import java.util.Scanner;
public class DA_1Q_C2_19BDS0119 {
Scanner sc=new Scanner(System.in).useDelimiter("\n");
void futurevisit()
{
String fvisit[]=new String[10];
System.out.println("Enter the places you want to visit in future with tentative year--");
System.out.println("Enter 'finish' when you entered all the place you wanted to visit in future!!");
System.out.println();
int x=0;
while(true)
{
System.out.print("Enter "+(x+1)+" place you want to visit in future with it's tentative year: ");
fvisit[x]=sc.next();
if(fvisit[x].equals("finish"))
break;
x++;
}
System.out.println();
for(int k=0;k<x;k++)
{
System.out.print((k+1)+" to visit: "+fvisit[k]);
System.out.println();
}
System.out.println();
}
public static void main(String[] args)
{
InternationalTravel o[]=new InternationalTravel[3];
NationalTravel o1[]=new NationalTravel[3];
DA_1Q_C2_19BDS0119 o2[]=new DA_1Q_C2_19BDS0119[3];
for(int i=0;i<3;i++)
{
o[i]=new InternationalTravel();
o1[i]=new NationalTravel();
o2[i]=new DA_1Q_C2_19BDS0119();
}
for(int i=0;i<3;i++)
{
o[i].getmethord();
o1[i].getmethord();
o[i].printmethord();
o1[i].printmethord();
o2[i].futurevisit();
}
}
}

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

- 6.b.Fast in java coding please. Thank you 1. Abstract classes and interfaces can both be used to model common features.How do you decide whether to use an interface or a class?2. What is Garbage Collection and how can you mark an object for GarbageCollection.arrow_forwardJAVA:arrow_forwardQuestion 14 Which is a process of hiding the implementation details and showing only functionality to the user?arrow_forward
- 1.Abstract classes, 2.abstract methods 3.Interfaces are three important OOP concepts. Give an example where each would be appropriate to usearrow_forwardIn the class diagram below we have a money class for an object-oriented parking system that is to be designed using java. Briefly explain any implementation decisions and the reasoning behind those without writing the complete code. N.B explain how the implementation will proceed instead of writing codearrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





