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

Java Programming Exam Questions

This document is an objective examination paper for a JAVA Programming course at Shri Vishnu Engineering College for Women. It includes multiple-choice questions covering topics such as multithreading, applets for web applications, and AWT for GUI applications. The exam is designed to assess students' understanding and practical skills in these areas within a 20-minute time frame.

Uploaded by

deptai2023
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)
9 views2 pages

Java Programming Exam Questions

This document is an objective examination paper for a JAVA Programming course at Shri Vishnu Engineering College for Women. It includes multiple-choice questions covering topics such as multithreading, applets for web applications, and AWT for GUI applications. The exam is designed to assess students' understanding and practical skills in these areas within a 20-minute time frame.

Uploaded by

deptai2023
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

SHRI VISHNU ENGINEERING COLLEGE FOR WOMEN:: BHIMAVARAM

(AUTONOMOUS)
IV B TECH I SEMESTER OBJECTIVE EXAMINATION - II
Subject Name: JAVA PROGRAMMING
Registered Number: Time : 20 Mins
Name of the Student: Max. Marks: 20*1/2 = 10 M
Branch Signature of the Invigilator

CO 4: Able to understand mulltithreading concept and develop multithreading programs


1 In JAVA multi threading, a thread can be created by_______ [ ]01
a) Extending class b) Implementing Runnable Interface
c) both d) none
2 Which method is used to make main thread to wait for all child threads [ ]02
a) Wait() b) Sleep() c) Join() d) Stop()
3 Which method is used to check if the thread is running [ ]03
a) isAlive() b) run() c) alive() d) keepAlive()
4 The life cycle of thread in JAVA is controlled by [ ]04
a) JDK b) JVM c) JRE d) None
5 Which method is used to get current running thread object? [ ]05
a) RunningThread() b) currentThread() c) runnableThread() d) None
6 Which of these method is used to explicitly set the priority of a thread? [ ]06
a) set() b) make() c) setPriority() d) makePriority()
7 Thread priority in Java is? [ ]07
a) Integer b) Float c) Double d) Long
CO 5: Able to practice and design applets for Web Applications
8 Which of these methods will respond when you click any button by mouse? [ ]08
a) mouseClicked() b) mouseEntered() c) mousePressed() d) all of the mentioned
9 Which of these events will be notified if scroll bar is manipulated? [ ]09
a) ActionEvent b) ComponentEvent c) AdjustmentEvent d) WindowEvent
10 Which applet [Link] class provides the life cycle method [ ]10
a) Public void paint(Graphics ) b) public void destroy()
c) public void stop() d) public void init()
11 Which of these methods can be used to change location of an event? [ ]11
a) ChangePoint() b) TranslatePoint() c) ChangeCordinates() d) TranslateCordinates()
12 Which of these are constants defined in WindowEvent class? [ ]12
a) WINDOW_ACTIVATED b) WINDOW_CLOSED
c) WINDOW_DEICONIFIED d) All of the mentioned
13 What is the default layout for Dialogs [ ]13
a)FlowLayout b) BorderLayout c) CardLayout d)GridLayout
14 Which alignment directions may be used with BoxLayout? [ ]14
a) Horizontal only b) Horizontal & Vertical
c) Left and Right aligned d) Centered and Justified
CO 6: Able to explain and design AWT for GUI Applications
15 Which one method is used to set the visibility of the frame? [ ]15
a) setVisible(true) b) setVisible(false) c) setVisible() d) None
16 Which method can set or change the text in a Label? [ ]16
a) setText() b) getText() c) All of the above d) None
17 Which package provides many event classes and Listener interfaces for event handling? [ ]17
a) [Link] b) [Link] c) [Link] d) None of the above
18 Which class is used to create a pop-up list of items from which the user may choose? [ ]18
a) List b) Choice c) Labels d) Checkbox
19 The following way is used to create a frame is by creating the object of Frame class? [ ]19
a) inheritance b) association c) Both A & B d) None of the above
20 Positions the components into five regions: east, west, north, south, center [ ]20
a) BorderLayout b) CardLayout c) GridLayout d) Flowlayout
SHRI VISHNU ENGINEERING COLLEGE FOR WOMEN:: BHIMAVARAM
(AUTONOMOUS)
IV B TECH I SEMESTER OBJECTIVE EXAMINATION - II
Subject Name: JAVA PROGRAMMING
Registered Number: Time : 20 Mins
Name of the Student: Max. Marks: 20*1/2 = 10 M
Branch Signature of the Invigilator

CO 4: Able to understand mulltithreading concept and develop multithreading programs


1 Which method is called internally by Thread start( ) method [ ]01
a) Execute( ) b) run( ) c) launch( ) d) start()
2 Which statements is/are correct [ ]02
a) On calling Thread start ( ) method a new thread is created
b)Thread start( ) method call run( ) method internally
c) Thread run( ) method can also be called directly to create thread d) both a & b
3 Which method we implement from runnable interface [ ]03
a) Run() b) Start() c) Execute() d) call()
4 What is maximum thread priority in Java [ ]04
a) 10 b) 12 c) 5 d) 8
5 If a priority of a JAVA thread is 3 then the default priority of its child thread will be [ ]05
a) 0 b) 1 c) 3 d) 5
6 Thread Synchronization in a process will be required when [ ]06
a) All thread share the same address space b) all threads share the same global variables
c) All threads sharing the same files d) all of these
7 Which of these are types of multitasking? [ ]07
a) Process based b) Thread Based c) Both A & B d) None
CO 5: Able to practice and design applets for Web Applications
8 Default Layout manager for subclass of "Window" is [ ]08
a) CardLayout b) GridBagLayout c) Frame d)BorderLayout
9 Which of these methods can be used to obtain the coordinates of a mouse? [ ]09
a) getPoint() b) getCoordinates() c) getMouseXY() d) getMouseCordinates()
10 The _______ interface is used to handle the menu events [ ]10
a) ContainerListener b) FocusListener c) ActionListener d) WindowListener
11 Which of these methods are used to register a keyboard event listener? [ ]11
a) KeyListener() b) addKistener() c) addKeyListener() d) eventKeyboardListener()
12 Event class is defined in which of these libraries? [ ]12
a) [Link] b) [Link] c) [Link] d) [Link]
13 Which of these interfaces define a method actionPerformed()? [ ]13
a) ComponentListener b) ContainerListener c) ActionListener d) InputListener
14 The constructor for Font class is [ ]14
a) Font(String name) b) Font(String name, int style, int size)
c) Font(String name, int size) d) Font(String name, int style)
CO 6: Able to explain and design AWT for GUI Applications
14 The Swing Component classes that are used in Encapsulates a mutually exclusive set of buttons? [ ]14
a) AbstractButton b) ButtonGroup c) Jbutton d) ImageIcon
15 Which are passive controls that do not support any interaction with the user? [ ]15
a) Choice b) List c) Labels d) Checkbox
16 Where can the event handling code be written? [ ]16
a) Same class b) Other class c) Anonymous Class d) All of the above
17 Which class is used to create a pop-up list of items from which the user may choose? [ ]17
a) List b) Choice c) Labels d) Checkbox
18 Positions the components into five regions: east, west, north, south, center [ ]18
a) BorderLayout b) CardLayout c) GridLayout d) Flowlayout
_________ generates action events when an item is double-clicked, generate action events when an
19 item is selected or deselected [ ]19
a) List b) Check box c) Menu item d) Text box
20 A label is a simple control which is used to display_____________ on the window [ ]20
a) Text(Non-editable) b) Text(editable) c) Both a & b d) none of these

Common questions

Powered by AI

The method used to check if a thread is still running in Java is 'isAlive()'. This method returns true if the thread upon which it is called is still alive, meaning it has been started and has not yet died. Knowing whether a thread is alive can help in managing concurrency and synchronization in a program, allowing developers to determine the state of thread execution and make decisions accordingly .

The method used to make the main thread wait for the completion of all its child threads is join(). By invoking join() on a child thread, the main thread enters a waiting state until the child thread completes its execution. This ensures that the main thread's execution continues only after its child threads have completed, preventing premature termination of processes that are dependent on the completion of those threads, and facilitating smooth data synchronization and state consistency .

Thread synchronization in Java ensures that shared resources or data are accessed by only one thread at a time, preventing data corruption and inconsistencies. However, it can significantly affect performance by introducing delays due to the overhead of acquiring locks and managing waiting threads. KEY factors for implementing synchronization include resource contention, the critical section duration, and the choice of synchronization techniques (e.g., synchronizing methods, synchronized blocks). Balancing protection and performance involves minimizing synchronized code regions and leveraging Java's concurrent collections and constructs, reducing idle times and fostering parallelism .

In Java, implementing a thread using the Runnable interface involves defining a class that implements Runnable and its run() method, then passing an instance of this class to a Thread object. On the other hand, extending the Thread class requires subclassing Thread and overriding its run() method. Runnable interface is preferred in cases where the class has to extend another class, promoting multiple inheritance. Extending Thread, however, is simpler and provides direct control over thread methods, but restricts further class inheritance due to Java's single inheritance model .

The setPriority() method in Java threading assigns a priority level to a thread, influencing the order in which threads are scheduled for execution. By altering thread priority, developers can suggest the relative importance of threads, aiding in optimizing resource allocation and maintaining smooth execution of critical tasks. However, the actual influence on execution order is heavily dependent on how the JVM interacts with the OS thread scheduler. Thus, while it can help in optimizing performance scenario, it should be used with caution and not as a sole means of thread execution control .

Thread priority in Java is used to prioritize the execution of threads, with higher priority threads getting preference over lower priority ones during thread scheduling. However, thread priority does not guarantee an order of execution as thread scheduling is dependent on the operating system's thread scheduler. The priority range in Java standardly spans from 1 to 10, with 5 being the default norm. Despite setting priority, real-time thread behavior depends heavily on the JVM's interaction with the underlying OS’s thread scheduling policies, which may not honor these priorities strictly .

GridBagLayout is preferable in complex interfaces where components need to be aligned in a flexible grid system that can vary in size with different components occupying multiple rows and columns. It offers high flexibility for designing forms with uneven rows and columns widths/sizes, unlike BorderLayout, which is limited to arranging components in North, South, East, West, and Center regions, or CardLayout, which only allows stacking components, showing one at a time. GridBagLayout provides the most granularity in component sizing and alignment, suited for highly customized GUIs .

The GridLayout manager in Java GUI applications organizes components in a rectangular grid, where each component is of equal size. This is suitable for creating forms or grids where the uniformity of elements is required. On the other hand, FlowLayout arranges components in a line, one after the other. It is similar to how text is arranged in a paragraph, flowing across a row until there's no more space, then moving to the next line. This makes FlowLayout more flexible in terms of component sizes compared to GridLayout, which standardizes component sizes to fit the grid .

The ActionListener interface in Java is used for handling action events generated, say, by button clicks. This interface contains the method actionPerformed(ActionEvent e) that needs to be implemented to define the response to user interactions with GUI components. By registering an object that implements ActionListener with a GUI component (like a JButton), the component generates action events listened to and processed by the actionPerformed method, enabling interactive applications .

The Choice class in Java AWT provides a compact way to present a list of options for user selection in a drop-down style menu, which occupies less screen space compared to List components. Unlike List, which can show multiple visible selections and requires more screen real estate, Choice is effective where space conservation is important and the options are few enough not to overwhelm user navigation. Choice also simplifies user interface design by ensuring a single selection, making it particularly suitable for scenarios with constrained UI layouts .

You might also like