Uploaded by Arslan Haider

Data

advertisement
Q1: if you are required to make a Notepad application which framework you will use?
What components you will add to your program? List them. Can you identify one
problem in current Notepad application that needs to be resolved?
I’ll use Javafx framework for this kind of application. And for that I need Manubar
and manus items for navigations or save or load the file from the computer. And I
need a TextArea for the for writing the text and saving it and display the text.
Q2: Solution
A: public void mTwo is the override method in the super class.
B: public void mThree is the hidden method in the super class because the
static methods are hidden in the parent class similarly the mFour is also
hidden but the method is in the child class when we call mFour using child
object it will call the child’s class method.
C: if we call mOne using class name then the static method in the subclass
will call and when we call mOne using object name then the superclass
method will be called. The method is in the child class when we call mFour
using child object it will call the child’s class method
Q3: Solution:
import java.util.Random;
import java.util.Scanner;
public class MultiThreads {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println();
Thread randomNumber = new Thread(() -> {
Random random = new Random();
int randnumber = random.nextInt();
if(randnumber % 2 == 0)
System.out.println(randnumber +" is Even");
else System.out.println(randnumber+" is Odd");
});
System.out.println();
Thread squareOfNumber = new Thread(()->{
System.out.println("Enter a Number: ");
int square = scanner.nextInt();
System.out.println("Square is: "+Math.pow(square,2));
});
Thread fSeries = new Thread(() -> {
int a=0, b=1, c=0;
System.out.println("Enter number of FSeries: ");
int number = scanner.nextInt();
System.out.print("Fibonacci series:");
while (number >0)
{
System.out.print(c+" ");
a=b;
b=c;
c=a+b;
number = number -1;
}
});
System.out.println();
try{
fSeries.start();
fSeries.join();
squareOfNumber.start();
squareOfNumber.join();
randomNumber.start();
randomNumber.join();
}catch (InterruptedException e){
e.printStackTrace();
}
}
}
Download