1.
From the following statements which is a disadvantage of an java array?
Correct Answer
D. An array holds only one type of data
Explanation
An array holds only one type of data, which is a disadvantage because it restricts the flexibility of storing different types of data within the same array. This means that if we want to store multiple types of data, we would need to create separate arrays for each type, which can be cumbersome and inefficient.
2.
Which method returns the interrupted flag after that it sets the flag to false if it is true?
Correct Answer
B. Static interrupted()
Explanation
The correct answer is "static interrupted()". This method returns the interrupted flag and then sets it to false if it is true. This method is a static method, meaning it can be called directly on the Thread class without needing an instance of the Thread object. The "isInterrupted()" method also returns the interrupted flag, but it does not reset the flag to false. Therefore, the correct answer is "static interrupted()".
3.
Abbreviate the term POJO?
Correct Answer
A. Plain Old Java Object
Explanation
The term POJO stands for Plain Old Java Object. It refers to a Java object that is simple, without any special frameworks or dependencies. A POJO is a basic Java class that follows certain conventions and does not require any specific interfaces or base classes. It is used to represent data in a straightforward manner, making it easier to understand and maintain.
4.
The following two rules are defined by?
1. The parameters may differ in their type or number, or in both.
2. They may have the same or different return types.
Correct Answer
A. Method overloading
Explanation
The given rules state that parameters in a method can differ in type or number, and they can also have the same or different return types. This is a characteristic of method overloading, where multiple methods with the same name but different parameters are defined in a class. Therefore, the correct answer is method overloading.
5.
Which allows you to migrate your implementations over time without breaking
the code that depends on the public interface of your classes?
Correct Answer
C. Encapsulation
Explanation
Encapsulation allows you to migrate your implementations over time without breaking the code that depends on the public interface of your classes. This is because encapsulation hides the internal details of an object and only exposes a public interface, which can be accessed by other objects. By keeping the public interface consistent while making changes to the internal implementation, encapsulation ensures that the code depending on the public interface remains unaffected. Therefore, encapsulation is the correct answer for this question.
6.
Which is used for writing data to a file in file handling?
Correct Answer
B. FileOutputStream
Explanation
FileOutputStream is used for writing data to a file in file handling. FileInputStream, on the other hand, is used for reading data from a file. Therefore, the correct answer is FileOutputStream.
7.
In which state is the thread after invocation of start() method, but the thread Scheduler has not selected it to be the running thread?
Correct Answer
B. Runnable
Explanation
After the invocation of the start() method, the thread enters the Runnable state. In this state, the thread is ready to be scheduled and executed by the thread scheduler. However, the thread scheduler has not yet selected it to be the running thread. Therefore, the correct answer is Runnable.
8.
Which package is used for analyzing code during run time?
Correct Answer
A. java.lang.reflect
Explanation
The package java.lang.reflect is used for analyzing code during run time. This package provides classes and interfaces that allow programmatic access to information about the classes, methods, and fields of loaded classes. It provides the ability to inspect and modify the runtime behavior of applications. The other packages mentioned (java.awt, java.io, java.applet) do not specifically deal with analyzing code during run time.
9.
Which mechanism is provided to handle the runtime errors so that normal flow of the application can be maintained?
Correct Answer
A. Exception Handling
Explanation
Exception handling is the mechanism provided to handle runtime errors in a program. It allows the program to catch and handle exceptions, preventing them from causing the program to crash. By using try-catch blocks, the program can gracefully handle exceptions and continue with its normal flow. This ensures that the application can maintain its expected behavior even when unexpected errors occur.
10.
Which driver uses ODBC driver to connect to the database?
Correct Answer
A. JDBC-ODBC bridge driver
Explanation
The JDBC-ODBC bridge driver uses the ODBC driver to connect to the database. The JDBC-ODBC bridge is a Java library that allows Java applications to access databases through the ODBC interface. It acts as a bridge between the Java application and the ODBC driver, enabling the Java application to communicate with the database using the ODBC protocol. This driver is commonly used when there is a need to connect a Java application to a database that only has an ODBC driver available.
11.
Which is invoked after the init() method or browser is maximized?
Correct Answer
A. Public void start()
Explanation
The method public void start() is invoked after the init() method or when the browser is maximized. This method is part of the applet lifecycle and is called automatically by the browser when the applet is started or when it needs to be restarted. It is commonly used to start any thread or animation in the applet, or to resume any paused activity.
12.
Which class provides many methods for graphics programming?
Correct Answer
C. Java.awt.GrapHics
Explanation
The correct answer is java.awt.Graphics. This class provides many methods for graphics programming in Java. It is a part of the java.awt package, which stands for Abstract Window Toolkit. The java.awt.Graphics class allows developers to draw and manipulate graphics objects, such as lines, shapes, and text, on a graphical user interface. It provides methods for drawing and filling shapes, setting colors and fonts, and transforming coordinates, among other functionalities.
13.
Which statement provides an easy way to dispatch execution to different parts of your code based on the value of an expression?
Correct Answer
B. Switch
Explanation
The switch statement provides an easy way to dispatch execution to different parts of your code based on the value of an expression. It allows you to specify multiple cases, each representing a different possible value of the expression. When the expression matches a particular case, the corresponding block of code is executed. This is particularly useful when you have a large number of possible values and you want to avoid writing multiple if-else statements. The switch statement improves code readability and makes it easier to understand the logic of the program.
14.
Which field of StreamTokenizer if the token is a word, this filed contains the word that can be used in programming?
Correct Answer
B. Double nval
15.
Which method of string class in java is used to convert the boolean into String?
Correct Answer
A. Public static String valueOf(double I)
Explanation
The correct answer is "public static String valueOf(boolean I)". This method is used to convert a boolean value into a String. It takes a boolean parameter and returns a String representation of that boolean value.
16.
Which Exception occurs when a class is not found while dynamically loading a class using the class loaders?
Correct Answer
A. ClassNotFoundException
Explanation
The correct answer is ClassNotFoundException. This exception occurs when a class is not found while dynamically loading a class using the class loaders.
17.
Which driver Network connection is indirect that a JDBC client makes to a middleware process that acts as a bridge to the DBMS server?
Correct Answer
A. JDBC-Net
Explanation
JDBC-Net is the correct answer because it refers to the driver network connection that is indirect and made by a JDBC client to a middleware process acting as a bridge to the DBMS server. This indicates that the JDBC-Net driver allows the client to connect to the DBMS server through a middleware process, providing a layer of abstraction between the client and the server.
18.
Which Indicates a result set that cannot be updated programmatically in concurrency?
Correct Answer
B. CONCUR_READ_ONLY
Explanation
The correct answer is CONCUR_READ_ONLY because it indicates that the result set cannot be updated programmatically in concurrency. This means that any attempt to modify the data in the result set will result in an error. CONCUR_UPDATABLE, on the other hand, allows for programmatically updating the result set. "All of the above" and "None of the above" are not correct because they do not specifically address the ability to update the result set programmatically in concurrency.
19.
Which of the following is true about inheritance in Java?
I) Private methods are final.
II) Protected members are accessible within a package and inherited classes outside the package.
III) Protected methods are final.
IV) We cannot override private methods.
Correct Answer
A. 1, 2 and 4
Explanation
In Java, private methods are not inherited and therefore cannot be overridden. Protected members are accessible within the same package and can also be inherited by classes outside the package. This makes statements I and II true. However, protected methods are not final, so statement III is false. Therefore, the correct answer is 1, 2, and 4.
20.
What is the range of data type byte in Java?
Correct Answer
A. -128 to 127
Explanation
The range of the data type byte in Java is from -128 to 127. This means that a byte variable can hold integer values within this range, including both positive and negative numbers.
21.
Which data type value is returned by all transcendental math functions?
Correct Answer
C. Double
Explanation
Transcendental math functions such as sine, cosine, and logarithm involve complex calculations that often result in decimal values. The data type "double" is used to represent floating-point numbers with a higher precision compared to "float". Therefore, it is the most suitable data type to return the accurate and precise results of transcendental math functions.
22.
Which of the following can be operands of arithmetic operators?
Correct Answer
D. Both Boolean & Characters
Explanation
Arithmetic operators can be used with numeric operands to perform mathematical calculations. However, in some programming languages, such as Java, arithmetic operators can also be used with characters and boolean values. When used with characters, arithmetic operators can perform operations such as addition and subtraction based on the ASCII values of the characters. When used with boolean values, arithmetic operators can treat true as 1 and false as 0, allowing for calculations based on boolean logic. Therefore, both boolean and characters can be operands of arithmetic operators.
23.
Modulus operator, %, can be applied to which of these?
Correct Answer
C. Both Integers and floating – point numbers.
Explanation
The modulus operator, %, can be applied to both integers and floating-point numbers. It returns the remainder of a division operation. This means that it can be used to determine if a number is even or odd, or to perform cyclic calculations. It is commonly used in programming languages to perform operations involving remainders.
24.
Decrement operator, –, decreases value of variable by what number?
Correct Answer
A. 1
Explanation
The decrement operator, -, decreases the value of a variable by 1.
25.
Which of these methods can be used to output a string in an applet?
Correct Answer
C. DrawString()
Explanation
The drawString() method can be used to output a string in an applet. This method is specifically designed to draw text on the screen. It takes parameters like the string to be displayed, the x and y coordinates of the starting position, and the font style and size. By using this method, developers can easily display text in an applet and customize its appearance according to their requirements.
26.
Which of these methods is a part of Abstract Window Toolkit (AWT) ?
Correct Answer
B. Paint()
Explanation
The method "paint()" is a part of the Abstract Window Toolkit (AWT). This method is used to paint the graphics on a component. It is called automatically by the system when a component needs to be repainted, such as when it is first displayed or when it is resized. The paint() method allows developers to customize the appearance of components by implementing their own painting logic.
27.
Which of these is an incorrect array declaration?
Correct Answer
D. int arr[] = int [5] new
28.
Which of these is an incorrect Statement?
Correct Answer
A. It is necessary to use new operator to initialize an array.
Explanation
The correct answer is "It is necessary to use new operator to initialize an array." This statement is incorrect because arrays can be initialized without using the new operator. Arrays can be initialized using comma separated expressions surrounded by curly braces, and they can also be initialized when they are declared. Therefore, the correct answer is that none of the statements are incorrect.
29.
Which of these classes is not part of Java’s collection framework?
Correct Answer
D. Queue
Explanation
The correct answer is Queue. Queue is not part of Java's collection framework. Java's collection framework includes classes like Maps, Array, and Stack, but Queue is not included. Queue is a separate interface in Java that represents a collection of elements in a specific order. It is used for implementing FIFO (First-In-First-Out) data structures.
30.
What is Collection in Java?
Correct Answer
A. A group of objects
Explanation
A collection in Java refers to a group of objects. It is a data structure that allows storing and manipulating multiple objects as a single unit. Collections provide various methods and operations to add, remove, and retrieve objects efficiently. They are used to organize and manage data in a flexible and dynamic manner. Examples of collections in Java include ArrayList, LinkedList, and HashSet.
31.
Which of these keywords is not a part of exception handling?
Correct Answer
C. Thrown
Explanation
The keyword "thrown" is not a part of exception handling. The other three keywords, "try," "finally," and "catch," are used in exception handling to handle and manage exceptions that occur during the execution of a program. The keyword "thrown" is not a valid keyword in exception handling and is not used for any exception-related tasks.
32.
Which of these keywords must be used to handle the exception thrown by try block in some rational manner?
Correct Answer
D. Catch
Explanation
The keyword "catch" must be used to handle the exception thrown by the try block in a rational manner. The catch block allows programmers to specify the actions or code that should be executed when a specific type of exception is thrown. It provides a way to catch and handle exceptions, preventing the program from abruptly terminating and allowing for error handling and recovery.
33.
. Which of these is used to perform all input & output operations in Java?
Correct Answer
A. Streams
Explanation
Streams are used to perform all input and output operations in Java. They provide a convenient way to handle input and output operations by abstracting the underlying details. Streams can be used to read data from a source or write data to a destination, such as files, network connections, or even the console. They allow for efficient and flexible handling of input and output, making them an essential part of Java programming.
34.
. What does AWT stands for?
Correct Answer
C. Abstract Window Toolkit
Explanation
AWT stands for Abstract Window Toolkit. AWT is a set of Java libraries that provides a platform-independent way to create graphical user interfaces (GUIs). It includes a collection of classes and methods that allow developers to create windows, buttons, menus, and other GUI components. AWT is an integral part of the Java Foundation Classes (JFC), which provides a more advanced and flexible GUI framework for Java applications.
35.
Which of these is a type of stream in Java?
Correct Answer
C. Byte stream
Explanation
In Java, a byte stream is a type of stream that is used to read and write data in the form of bytes. It is commonly used for handling binary data or for reading and writing files byte by byte. Byte streams are useful when dealing with low-level I/O operations and when working with data that is represented as individual bytes.
36.
Which of the following is correct way of implementing an interface salary by class manager?
Correct Answer
B. Class manager implements salary {}
Explanation
The correct way of implementing an interface in a class is by using the "implements" keyword. Therefore, the correct answer is "class manager implements salary {}". This indicates that the class manager will implement the methods defined in the salary interface.
37.
Which of these is a mechanism for naming and visibility control of a class and its content?
Correct Answer
B. Packages
Explanation
Packages are a mechanism for naming and visibility control of a class and its content. They provide a way to organize and group related classes, interfaces, and other resources together. By using packages, we can avoid naming conflicts and control the visibility of classes and their members. Packages also facilitate modular programming and code reusability by allowing us to import and use classes from other packages.
38.
Which of this access specifies can be used for a class so that its members can be accessed by a different class in the same package?
Correct Answer
D. All of the mentioned
Explanation
All of the mentioned access specifies (public, protected, and no modifier) can be used for a class so that its members can be accessed by a different class in the same package. The public access specifies allows the class and its members to be accessed by any class in the same package. The protected access specifies allows the class and its members to be accessed by any subclass in the same package. The no modifier (also known as default or package-private) allows the class and its members to be accessed by any class in the same package. Therefore, all of these access specifies can be used to achieve the desired result.
39.
. Which of these access specifiers can be used for a class so that it’s members can be accessed by a different class in the different package?
Correct Answer
A. Public
Explanation
The public access specifier can be used for a class so that its members can be accessed by a different class in a different package. Public access allows unrestricted access to the class and its members from any other class or package. This means that the class and its members can be accessed and used by any other class, regardless of the package they belong to.
40.
Which of these class is superclass of String and StringBuffer class?
Correct Answer
B. Java.lang
Explanation
The correct answer is java.lang. The java.lang package is a default package in Java that contains classes that are fundamental to the language. Both the String and StringBuffer classes are part of this package. Therefore, java.lang is the superclass of both String and StringBuffer classes.
41.
Which of these operators can be used to concatenate two or more String objects?
Correct Answer
A. +
Explanation
The + operator can be used to concatenate two or more String objects. This operator is used to combine the contents of two strings into a single string. For example, if we have two strings "Hello" and "World", using the + operator we can concatenate them as "HelloWorld".