Exam Prep S.E.

What do anonymous classes represent in Java?
Classes defined inside other classes that cannot be instantiated
Classes defined inside methods or blocks from methods that are only visible locally
Classes defined inside other classes and do not have a certain name
Classes that dissapear after the program compiles the first time
What is the main difference between AWT and Swing in Java?
AWT is faster than Swing
Swing offers a richer set of graphical components
Swing is not Java-compatible
AWT is easier to learn than Swing
What is the use of the setContentPane() method in Java Swing?
Sets the window dimensions
Adds a container in a window
Sets the main content of a window
Activates click events
What is the role of the wait() method?
Awaits a notification from another execution thread
Prints the message "I was notified"
Enters an infinite loop
Waits for 2 seconds
Which of the following mechanisms are used to synchronize threads of execution in Java?
Wait/notify
Synchronized
Join
Sleep
Which of the following methods is used to add a component to a container in Java Swing?
AppendComponent(component);
Add(component);
AddComponent(component);
InsertComponent(component);
What in an enum in Java?
A type of data used for simplifying constant declaration
A type of class that cannot be instantiated
A type of variable used to store email adresses
A name by which we refer to arrays that count certain elements
What is serialization in Java?
A process of converting an object into a byte flux used to save and send objects
A process of converting a data type in another data type used for manipulating values
A process of encryption for data in Java
A process through which you give your program a unique serial number
What is the difference between abstract methods and final methods in Java?
Abstract methods cannot be overwritten, while final methods cannot be accesed from other classes.
Abstract methods do not have implementations, while final methods cannot be overwritten
Abstract methods are only used in abstract classes, while final methods are only used in final classes
Abstract and final methods do not have any differences
Which of the following is not a primitive type in Java?
Class
Int
Float
Boolean
What is an abstract class in Java?
A class that cannot be instantiated
A class that cannot be inherited
A class that cannot have other methods
An instance of an interface
What is an interface in Java?
An abstract class
A collection of variables
A collection of abstract methods
A collection of objects
What is polymorphism in Java?
The ability to create new objects from existing objects
The ability to extend the functionality of an existing class
The ability to split a class into multiple parts
The ability to use the same method in multiple different classes
What is inheritance in Java?
The ability to create new objects from existing objects
The ability to extend the functionality of an existing class
The ability to split a class into multiple parts
The ability to create a collection of similar objects
What is an object in Java?
An instance of a class
A primitive data type
A collection of methods
A collection of variables
What is a class in Java?
A primitive data type
A method used for creating objects
A collection of similar objects
A template for creating objects
What do exceptions represent in Java?
The mechanism used for treating errors while the program is being executed
Events generated and solved while compiling the programs
Special classes used for managing object collections
Events generated by the operating system
What does the List class represent in Java Collection Framework?
An element collection that does not allow duplicates
An element collection that allows duplicates
A key-value pair collection
A collection of ordered elements
What do synchronous and asynchronous messages represent in a sequence diagram?
Synchronous messages - messages that wait for a response; asynchronous messages - messages that do not wait for a response
Synchronous messages - messages that do not wait for a response; asynchronous messages - messages that wait for a response
Synchronous messages - messages sent between the same object; asynchronous messages - messages sent between different objects
Synchronous messages - messages that can only be sent between objects of the same class; asynchronous messages - messages sent between objects of different classes
Which is the distinctive characteristic of a Map?
Contains ordered elements
Does not allow duplicate values
Stocks pair of type key-value
Implements a stack-type structure
What happens after a Java program throws an exception?
The program continues to run normally
The execution of the program is stopped and it shows an error message
It shows an error message, but the execution of the program continues
A certain action defined in the "Catch" block happens
Which of the following classes are part of the Swing library?
JFrame
JLabel
JButton
All of the above
What will be the output of the previous code snippet?
Ee
Null
An exception
It will not compile
What is the meaning of the following relationship in the UML diagram? (A and B are classes)
Composition (B has an attribute of type A)
A extends B
Aggregation (A has an attribute of type B)
Association (B has an attribute of type A)
What is the meaning of the following relationship in the UML diagram? (A and B are classes)
Association ( A has an attribute of type B)
A extends B
Aggregation (B has an attribute of type A)
Composition (A has an attribute of type B)
What is the meaning of the following relationship in the UML diagram? (A and B are classes)
A depends on B
A extends B
B implements A
Aggregation (A has an attribute of type B)
What is the purpose of using buffers in input/output streams?
Reduce unnecessary network traffic
Increase the efficiency of reading and writing data
Allow working with encrypted files
Eliminate the need for try-catch blocks in exception handling code
What is the role of a layout manager in graphical interfaces in Java?
Managing the arrangement of graphical components on the page
Validating and processing user inputs
Displaying user data
All of the above
Which of the following classes is used for event handling in Java Swing?
ActionListener
MouseEvent
KeyListener
All of the above
What is the library used for working with graphical interfaces in Java?
Java FX
AWT
Swing
All of the above
What are the basic elements of an activity diagram?
End point
Threads of execution
Decision and junction point
Start point
Timed Signals
Send/receive signals
What is the main purpose of the Model-View-Controller (MVC) in graphic interfaces?
Separation of concerns and flexible coupling of components
Displaying user data
Processing user inputs
All of the above
Which of the following keywords are access modifiers?
Public
Protected
Forbidden
Blocked
The Static Polymorphism is based on
Aggregation
Method overloading
Method overriding
Composition
The keyword volatile is used to
Ensure that variables cannot be accessed in multiple threads
Ensure that shared variables are consistenly updated by multiple threads
Create variables that are lightweight
Create lightweight classes
The keyword synchronized is used to:
Implement mutual exclusion
Ensure that a method is executed simultaneously on multiple threads
Create synchronous variables
Ensure that two Java applications start at the same time
What method from class Thread should be overriden in order to implement the logic of a new thread?
Start();
Run();
Runtime();
Synchronized();
What is ObjectOutputStream used for?
To serialize objects
To deserialize objects
To read from text file
To write into text files
What type of exception is ArrayIndexOutOfBoundsException?
Unchecked (runtime) exception
Checked (compile time) exception
Error
Random exception
What type of collection does not extend the Collection interface?
List
Map
Queue
Set
What type of Set is sorted?
HashSet
LinkedHashSet
TreeSet
SortedBySet
What type of Map stores the objects in the order in which they are inserted?
HashMap
LinkedHashMap
TreeMap
AdditionOrderedMap
Is Array-List thread-safe?
Yes
No
Only if it contains primitive values
Yes, if it only contains Strings
What type of design pattern is Iterator?
Creational
Behavioral
Structural
Primitive
Select the reference types in Java
Integer
Boolean
String
Int[]
What type of design pattern is Observer?
Creational
Behavioral
Structural
Primitive
What is the design pattern prototype used for?
To ensure a class cannot be extended
To ensure a class cannot be instantiated
To ensure a class can be instantiated only once
To clone existing objects when objects creation is expensive
What is the design pattern Factory used for?
It is used to instantiate classes that have lots of attributes
It is used to instantiate classes that have a single attribute
It is used in industrial Java applications
It is used to hide the complex creation factor from client code
What is the meaning of the keyword void in Java?
The method has no parameter
The method doesn't return anything
The method returns null
The method returns 0
Which of the following are the main Java stream categories?
Image streams
Byte streams
Character streams
Number streams
Which of the following are byte streams?
FileWriter
FileReader
FileInputStream
FileOutputStream
Consider two String variables a and b. How do you correctly verify that their values are equal in Java?
A.equals(b);
A=b;
A===b;
A.eq(b);
How do you correctly declare and instantiate an array of 10 integers in Java?
int [10];
Int[] v = new int[10];
Int[] v = new int[9];
Int[] v;
Which of the following are techniques used for code reuse?
Aggregation.
Inheritance.
Composition.
Polymorphism.
Which of the following are basic concepts in OOP?
Inheritance
Composition
Polymorphism
Aggregation
How are variables declared in interfaces by default?
Private
Public
Static
Final
Dynamic polymorphism is based on:
Multifunctions
Aggregation
Composition
Inheritance
What is the role of the word "this"?
Refers to the current object
Declares a class variable
Refers to the constructor of the base class
Helps access the common interface of objects
What is the role of the word "super"?
Refers to the current object
Allows referencing members from the base class
Is used to declare super-classes
Helps access the common interface of objects
What do you understand by method overloading?
A sequence of code that forces the processor
Multiple methods with the same name and different parameter lists
Forced modification of static variables
Modifying an inherited method
How is the protected access specifier represented in a UML class diagram?
#
~
-
+
The final keyword is used for:
Declaring volatile variables
Declaring constants
Declaring classes that cannot be extended (inherited)
Declaring methods that cannot be overridden
The static keyword is used for:
Declaring instance members
Declaring class members
A static member cannot be modified
A static variable is not collected by the garbage collector
Consider the following code sequence: int[] arr = {1, 2, 3, 4}; System.out.println(arr[1]); In the console, the output will be:
1
2
3
4
What is the extension of Java compiled files?
Class
Jar
Byte
Java
How many parameters does the implicit constructor have?
0
1
2
3
An asbtract class can have:
Only methods with implementation
Only methods without implementation
Both methods with implementation and methods without implementation
Cannot have methods, only abstract attributes
What is the keyword used for inheritance implementation?
Implements
Inherits
Extends
Super
Starting with Java 8, an interface can have:
Only methods with implementation
Only methods without implementation
Both methods with implementation and methods without implementation
There are no interfaces in Java
Which of the following blocks is always executed, regardless of whether an exception is thrown or not?
Try
Catch
Throw
Finally
Where is a method declared in an interface visible by default (without any access specifier)?
Only inside the interface (private)
In all classes from all packages (public)
Only in the current package (package)
Only in the current package and in the classes that implement the interface
What will the following code snippet print? Int a = 3; System.out.println(++a);
1
2
3
4
What is the base class, implicitly inherited by all classes in Java?
Base
Class
Object
String
In which category of design patterns does Singleton belong?
Creational
Structural
Behavioral
Thread-safe
Which design pattern is used mostly in the context of graphical interfaces?
Singleton
Factory
Model-View-Controller
Prototype
Which type of exceptions does not require mandatory handling (try-catch OR throws) to compile Java code?
Runtime exceptions
Compile-time exceptions
Explicit handling of all exceptions is mandatory
No exception handling is mandatory to compile a Java application
Which category of design patterns does the Decorator belong to?
Creational
Structural
Behavioral
Thread-safe
Which design pattern is used for cloning existing objects when instantiation is expensive?
Singleton
Factory
Iterator
Prototype
{"name":"Exam Prep S.E.", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"What do anonymous classes represent in Java?, What is the main difference between AWT and Swing in Java?, What is the use of the setContentPane() method in Java Swing?","img":"https://www.quiz-maker.com/3012/CDN/102-5025531/image-2024-06-13-142711324.png?sz=1200"}
Make your own Survey
- it's free to start.