Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Questions 1: Select the right option. (10)
- 1) Every enum constant is always implicitly
- a) public
- 2) static
- 3) final
- 4) all three.
- 2) A layout is placed on ____ to be displayed. (JavaFX)
- a) Stage
- b) Scene
- c) Group
- d) Parent
- 3) Button class is a subclass of ____
- a) Node
- b) Label
- c) Scene
- d) Window
- 4) We can create a reference variable of ____
- a) Class
- b) Interface
- c) Both
- 5) Can we use the instance variable of class in that static variable of the same class?
- a) Yes
- b) No
- c) We need to create its object
- d) Just using class name would work.
- 6) Static methods can refer to
- a) this
- b) super
- c) none of these
- d) both
- 7) Which of these are valid in an interface
- a) static int x() { /*MuHaHaHa*/}
- b) int x = 0;
- c) double hello();
- d) all of these.
- e) none of these.
- 8) Which exception must be caught if it's thrown by a method
- a) Run time Exception.
- b) Compile time Exception.
- c) None.
- d) Both.
- 9) JCheckBox specialty is:
- a) Only one in the group can be selected.
- b) All can be selected at once.
- c) They make a beep sound when selecting by default.
- d) none just like normal list selection buttons.
- 10) What can be used for placing the components in java swing:
- a) JPane
- b) JFrame
- c) JTextArea
- d) a and b.
- e) a and c.
- f) a,b and c.
- g) none.
- Question 2: Short questions (6)
- What is the difference between VBox, HBox, and StackPane (JavaFX)? (3)
- What is the difference between ArrayList and simple array, how to declare it and give its example? (3)
- Question 3: Find the compile-time errors and fix them (10)
- Code 1: (2)
- public static int sum(int x, int y) throws IOException
- {
- throw new IOException("Error ha");
- }
- public static void main(String args[])
- {
- sum(1,2);
- }
- Code 2: (2)
- float f = 8.0;
- double d = 7.0;
- int i = 0;
- public void justAnMethod() {
- System.out.printf("%f,%d,%i",f,d,i);
- }
- code 3: (2)
- import javax.swing.*;
- import java.awt.event.ActionListener;
- public class MyFrame extends JFrame implements ActionListener
- {
- public MyFrame()
- {
- super();
- }
- }
- code 4: (4)
- public interface A {
- void hello();
- }
- public class B {
- abstract public void bye();
- }
- public class C extends B implements A {
- public void hello() {
- return;
- }
- }
- public class D extends C implements A {
- @Override
- public void bye() {
- }
- @Override
- public void hello() {
- }
- }
- Question 4: (4)
- Your connection has been established to the database and stored in variable 'connection';
- Store data in table and then load all the data.
- When you have loaded all the data print only the data which you just added.
- Queries to use:
- For Saving:
- INSERT INTO Account (Name,Pass,Date) VALUES ('Arose','Niazi',NOW())
- For Loading:
- SELECT * FROM Account
- Question 5: (10)
- Write a paint program, keep it simple just too one color.
- Question 6: (10)
- Determine the output
- Code 1: (2)
- public class A {
- public static void main(String[] args)
- {
- if (true)
- break;
- }
- }
- Code 2: (2)
- class Test1 {
- Test1(int x) {
- System.out.println("Constructor called " + x);
- }
- }
- class Test2 {
- Test1 t1 = new Test1(10);
- Test2(int i) { t1 = new Test1(i); }
- public static void main(String[] args) {
- Test2 t2 = new Test2(5);
- }
- }
- Code 3: (2)
- class Test2 {
- public static void main(String[] args)
- {
- int arr[][] = { { 11, 22 }, { 33, 44, 55 } };
- for (int i = 0; i < 2; i++) {
- for (int j = 0; j < arr.length; j++)
- System.out.print(arr[i][j] + " ");
- System.out.println();
- }
- }
- }
- Code 4: (2)
- interface A
- {
- void myMethod();
- void getInfo();
- }
- abstract class B implements A
- {
- void getData()
- {
- System.out.println("A");
- }
- }
- public class Test extends B
- {
- public void myMethod()
- {
- System.out.println("D");
- }
- public void getInfo()
- {
- System.out.println("B");
- }
- public static void main(String[] args)
- {
- B obj = new Test();
- obj.getInfo();
- }
- }
- Code 5:
- public static void main(String args[])
- {
- boolean b[] = new boolean[52];
- b[26]=true;
- while(!b[b.length/2])
- {
- System.out.print("***");
- }
- int x=0;
- while (true)
- {
- if(++x < 5) System.out.print("A");
- else break;
- }
- for(x=b.length/2-2; x<b.length; x++)
- {
- if(b[x])
- {
- System.out.print("***");
- break;
- }
- else
- System.out.print("B");
- }
- }
Add Comment
Please, Sign In to add comment