Java Programming: Ultimate Quiz! MCQ

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Rushikesh
R
Rushikesh
Community Contributor
Quizzes Created: 4 | Total Attempts: 4,191
| Attempts: 308 | Questions: 20
Please wait...
Question 1 / 20
0 %
0/100
Score 0/100
1. Which of the following is a method having same name as that of its class?

Explanation

A constructor is a method that initializes an object immediately upon creation. It has the same name as that of class in which it resides

Submit
Please wait...
About This Quiz
Java Programming: Ultimate Quiz! MCQ - Quiz

Dive into the Java Programming: Ultimate Quiz! MCQ to test and enhance your Java knowledge. This quiz covers fundamental aspects like data types, operators, and control statements, helping learners confirm their understanding and readiness in Java programming.

Tell us your name to personalize your report, certificate & get on the leaderboard!
2. Which of these values can a boolean variable contain?

Explanation

Explanation: Boolean variable can contain only one of two possible values, true and false.

Submit
3. Which of these cannot be declared static?

Explanation

Explanation: static statements are run as soon as class containing then is loaded, prior to any object declaration.

Submit
4. Which of this method of class String is used to obtain the length of String object?

Explanation

Explanation: Method length() of string class is used to get the length of the object which invoked method length().

Submit
5. Which of these are selection statements in Java?

Explanation

Explanation: continue and break are jump statements, and for is an looping statement.

Submit
6. Which of these keywords can be used to prevent Method overriding?

Explanation

Explanation: To disallow a method from being overridden, specify final as a modifier at the start of its declaration. Methods declared as final cannot be overridden.

Submit
7. Which of these keywords is not a part of exception handling?

Explanation

Explanation: Exceptional handling is managed via 5 keywords – try, catch, throws, throw and finally.

Submit
8. What is the value stored in x in following lines of code?int x, y, z;x = 0;y = 1;x = y = z = 8;

Explanation

Explanation: none

Submit
9. Which of the following are legal lines of Java code? 1. int w = (int)888.8; 2. byte x = (byte)100L; 3. long y = (byte)100; 4. byte z = (byte)100L;  

Explanation

Explanation: Statements (1), (2), (3), and (4) are correct. (1) is correct because when a floating-point number (a double in this case) is cast to an int, it simply loses the digits after the decimal.(2) and (4) are correct because a long can be cast into a byte. If the long is over 127, it loses its most significant (leftmost) bits.(3) actually works, even though a cast is not necessary, because a long can store a byte.

Submit
10. Which of these method of class StringBuffer is used to concatenate the string representation to the end of invoking string?

Explanation

The method append() of class StringBuffer is used to concatenate the string representation to the end of the invoking string. This method appends the specified string to the existing string and returns a reference to the modified StringBuffer object. It is commonly used to build longer strings by appending smaller strings together.

Submit
11. Which of these methods is an alternative to getChars() that stores the characters in an array of bytes?

Explanation

Explanation: getBytes() stores the character in an array of bytes. It uses default character to byte conversions provided by the platform.

Submit
12. Which of these is a mechanism for naming and visibility control of a class and its content?

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.

Submit
13. Which of these is a process of extracting/removing the state of an object from a stream?

Explanation

Explanation: Deserialization is a process by which the data written in the stream can be extracted out from the stream.

Submit
14. Which of these is a super class of wrappers Double and Float?

Explanation

Explanation: Number is an abstract/super class containing subclasses Double, Float, Byte, Short, Integer and Long.

Submit
15. Which of these can be returned by the operator & ?

Explanation

Explanation: We can use binary ampersand operator on integers/chars (and it returns an integer) or on booleans (and it returns a boolean).

Submit
16. Which of this method of an Object class can clone an object?

Explanation

The correct answer is "Object clone()". This method is a part of the Object class in Java and is used to create a copy or clone of an object. It returns a new object that is a copy of the original object.

Submit
17.  A class member declared protected becomes member of subclass of which type?

Explanation

Explanation: A class member declared protected becomes private member of subclass.

Submit
18. Which of these methods is used to compare a specific region inside a string with another the specific region in another string?

Explanation

The method regionMatches() is used to compare a specific region inside a string with another specific region in another string.

Submit
19. Which of these is an interface for control over serialization and deserialization?

Explanation

Externalization is an interface for control over serialization and deserialization. It allows developers to have more control over the serialization process by implementing the Externalizable interface and providing their own custom serialization logic. This interface provides two methods, writeExternal() and readExternal(), which allow objects to write and read their own state in a customized manner. This is different from the Serializable interface, which provides a default serialization mechanism. FileFilter and ObjectInput are not interfaces for control over serialization and deserialization.

Submit
20. On applying Left shift operator, <<, on an integer bits are lost one they are shifted past which position bit?

Explanation

Explanation: The left shift operator shifts all of the bits in a value to the left specified number of times. For each shift left, the high order bit is shifted out and lost, zero is brought in from the right. When a left shift is applied to an integer operand, bits are lost once they are shifted past the bit position 31.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 21, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Sep 20, 2017
    Quiz Created by
    Rushikesh
Cancel
  • All
    All (20)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Which of the following is a method having same name as that of...
Which of these values can a boolean variable contain?
Which of these cannot be declared static?
Which of this method of class String is used to obtain the length...
Which of these are selection statements in Java?
Which of these keywords can be used to prevent Method overriding?
Which of these keywords is not a part of exception handling?
What is the value stored in x in following lines of code?int x,...
Which of the following are legal lines of Java code?...
Which of these method of class StringBuffer is used to...
Which of these methods is an alternative to getChars() that...
Which of these is a mechanism for naming and visibility control...
Which of these is a process of extracting/removing the state of...
Which of these is a super class of wrappers Double and Float?
Which of these can be returned by the operator & ?
Which of this method of an Object class can clone an object?
 A class member declared protected becomes member of...
Which of these methods is used to compare a specific region...
Which of these is an interface for control over serialization and...
On applying Left shift operator, <<, on an integer bits are...
Alert!

Advertisement