Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CSE 234, LAB FINAL
- MARKS: 100, TIME: 30 MIN
- [*Create a folder named after your registration number on the desktop and keep all answer files in there*]
- [*All class, method and variable names that are provided should be kept same(case sensitive) as it is.*]
- Q1. Write a java class using the following information: 20
- public class S {
- public static void changeMainThread(int sec, int priority) {
- . . .
- . . .
- }
- public static void main (String args[]) {
- S.changeMainThread(3, 9);
- }
- }
- OUTPUT:
- Current Thread: Thread[main,5,main]
- Current Thread: Thread[ExamThread,9,main]
- Threading is trying sleeping for 3s...
- Sleeping complete!
- Q2. Write two java class file using the following information: 35
- public abstract class A {
- private int ai;
- ...
- ...
- public int am1() { return ai; }
- public abstract void am2(String s); // Prints reversed string.
- }
- public class B extends A {
- private int bi;
- ...
- ...
- public void bm() {
- System.out.println("ai : " + am1() + "\nbi : " + bi);
- }
- ...
- ...
- public static void main(String args[]) {
- B b = new B(10,20);
- b.bm();
- A a = b;
- a.am2("APPLE");
- }
- }
- OUTPUT:
- ai : 10
- bi : 20
- ELPPA
- Q3. Write two java class file using the following information: 25
- interface I {
- int fi = 5;
- void im(int n);// prints factorial of n
- }
- public class C extends B implements I {
- ...
- ...
- ...
- public static void main(String args[]) {
- C c = new C(40,25);
- c.bm();
- c.am2("Factorial");
- c.im(c.fi);
- S.changeMainThread(2,8);
- }
- }
- OUTPUT:
- ai : 40
- bi : 25
- lairotcaF
- 120
- Current Thread: Thread[main,5,main]
- Current Thread: Thread[ExamThread,9,main]
- Threading is trying sleeping for 3s...
- Sleeping complete!
- Q4. Create packages with the class files from Q1-3 accordingly so that all previous codes works as it should be.
- Package folders should be directly under the Registration number directory. Packages: 20
- Package Name Class
- p1 S
- p2 A
- B
- p3 I
- C
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement