1.
What is the range of byte data type in Java?
Correct Answer
A. -128 to 127
Explanation
Explanation: Byte occupies 8 bits in memory. Its range is from -128 to 127.
2.
Which of these coding types are used for data type characters in Java?
Correct Answer
C. UNICODE
Explanation
Explanation: Unicode defines fully international character set that can represent all the characters found in all human languages. Its range is from 0 to 65536.
3.
Literals in java must be appended to which of these?
Correct Answer
D. L and I
Explanation
Explanation: Data type long literals are appended by an upper or lowercase L.
4.
What is the prototype of the default constructor of this class?
Correct Answer
D. Public prototype( )
Explanation
The correct answer is "public prototype( )". This is the prototype of the default constructor of the class. The "public" keyword indicates that the constructor is accessible from any other class. The "prototype" keyword is the name of the constructor, and the empty parentheses indicate that it does not take any parameters.
5.
Which of these is an incorrect array declaration?
Correct Answer
D. Int arr[] = int [5] new
Explanation
Explanation: Operator new must be succeeded by array type and array size.
6.
With x = 0, which of the following are legal lines of Java code for changing the value of x to1?- x++;
- x = x + 1;
- x += 1;
- x =+ 1;
Correct Answer
C. 1, 2, 3 & 4
Explanation
Operator ++ increases value of variable by 1. x = x + 1 can also be written in shorthand form as x += 1. Also x =+ 1 will set the value of x to 1.
7.
Which operator is used to invert all the digits in the binary representation of a number?
Correct Answer
A. ~
Explanation
Explanation: Unary not operator, ~, inverts all of the bits of its operand in binary representation.
8.
Which of these is returned by “greater than”, “less than” and “equal to” operators?
Correct Answer
C. Boolean
Explanation
Explanation: All relational operators return a boolean value ie. true and false.
9.
What should be expression1 evaluate to in using the ternary operator as in this expression1 ? expression2 : expression3line?
Correct Answer
C. Boolean
Explanation
Explanation: The controlling condition of ternary operator must evaluate to boolean.
10.
Which keyword is used by the method to refer to the object that invoked it?
Correct Answer
D. This
Explanation
Explanation: this keyword can be used inside any method to refer to the current object. this is always a reference to the object on which the method was invoked.
11.
Which of this keyword is used to make a class?
Correct Answer
A. Class
Explanation
The keyword "class" is used to make a class in programming. A class is a blueprint or template for creating objects, and it defines the properties and behaviors that an object of that class will have. In many programming languages, including Python, "class" is the keyword used to define a new class. Therefore, the correct answer is "class".
12.
Which of these can be overloaded?
Correct Answer
C. All of the mentioned
Explanation
In object-oriented programming, overloading refers to the ability to define multiple methods or constructors with the same name but different parameters. This allows for flexibility and convenience when working with different data types or varying numbers of arguments. Therefore, both methods and constructors can be overloaded. By overloading methods or constructors, developers can create more versatile and reusable code.
13.
Which of these is used to access member of class before the object of that class is created?
Correct Answer
C. Static
Explanation
The keyword "static" is used to access members of a class before an object of that class is created. Static members belong to the class itself rather than to any specific instance of the class. They can be accessed using the class name followed by the member name, without the need for an object to be created. This allows for the use of class variables and methods without the need to instantiate an object of the class.
14.
Which of these keywords is used to prevent content of a variable from being modified?
Correct Answer
A. Final
Explanation
Explanation: A variable can be declared final, doing so prevents its content from being modified. Final variables must be initialized when it is declared.
15.
Which of this method of String class is used to obtain character at specified index?
Correct Answer
D. CharAt()
Explanation
The correct answer is charAt(). The charAt() method is used to obtain the character at a specified index in a String. It takes an index as a parameter and returns the character at that index.
16.
Which of these operators can be used to concatenate two or more String objects?
Correct Answer
A. +
Explanation
Explanation: operator + is used to concatenate strings, Example String s = “i ” + “like ” + “java”; String s contains “I like java”.
17.
Which of these is a mechanism for naming and visibility control of a class and its content?
Correct Answer
B. Packages
Explanation
Explanation: Packages are both naming and visibility control mechanism. We can define a class inside a package which is not accessible by code outside the package.
18.
Which of these process occur automatically by java runtime system?
Correct Answer
A. Serialization
Explanation
Serialization and deserialization occur automatically by java runtime system, Garbage collection also occur automatically but is done by CPU or the operating system not by the java runtime system.
19.
Which of this interface is implemented by Thread class?
Correct Answer
A. Runnable
Explanation
The correct answer is Runnable. The Thread class in Java implements the Runnable interface. This interface provides a way to define a task that can be executed concurrently by multiple threads. The Runnable interface has a single method called run(), which contains the code that will be executed when the thread is started. By implementing the Runnable interface, the Thread class can be used to create and control threads in Java.
20.
What does AWT stand for?
Correct Answer
C. Abstract Window Toolkit
Explanation
Explanation: AWT stands for Abstract Window Toolkit, it is used by applets to interact with the user.