Practice
Resources
Contests
Online IDE
New
Free Mock
Events New Scaler
Practice
Improve your coding skills with our resources
Contests
Compete in popular contests with top coders
logo
Events
Attend free live masterclass hosted by top tech professionals
New
Scaler
Explore Offerings by SCALER

Java MCQ

Last Updated: Jan 08, 2024
Image
Image
Image Certificate included
Image About the Speaker
Image
What will you Learn?
Register Now
Image
ai interview ai interview

Java is a high-level, general-purpose, object-oriented programming language. It is easy and used to develop any kind of program. Apart from this, it can also be used in Android development.

Editions of Java

  • Java mainly has three editions -
  • Java Standard Edition(SE): develop applications that run on the desktop.
  • Java Enterprise Edition(EE): develop server-side applications.
  • Java Micro Edition(ME): develop applications for mobile devices.

Java Development Kit

  • Set of programs that enable us to develop our programs.
  • Contains JRE(Java Runtime Environment) that is used to run our programs.

Java Architecture

  • Java Architecture consists of three main components:
  • JVM: One of the main features of Java is Write Once Run Anywhere, i.e. it is platform-independent. It can run on any OS irrespective of the environment because of Java Virtual Machine.
  • JRE: Java Runtime Environment provides an environment for the Java programs to be executed.
  • JDK: It is the software development environment that is mainly used in the development of Java applications and applets.

Java MCQ Questions

1. 

Number of primitive data types in Java are?

Image Image
Create a free personalised study plan Create a FREE custom study plan
Get into your dream companies with expert guidance
Get into your dream companies with expert..
Image Real-Life Problems
Image Prep for Target Roles
Image Custom Plan Duration
Image Flexible Plans
2. 

What is the size of float and double in java?

3. 

Automatic type conversion is possible in which of the possible cases?

4. 

Find the output of the following code.

int Integer = 24;
char String  = ‘I’;
System.out.print(Integer);
System.out.print(String);
5. 

Find the output of the following program.

public class Solution{
       public static void main(String[] args){
                     short x = 10;
                     x =  x * 5;
                     System.out.print(x);
       }
}
Image Explore InterviewBit’s Exclusive Live Events
Explore Exclusive Events
By Image
Image
No More Events to show!
Image
No More Events to show!
Image
No More Events to show!
Image
No More Events to show!
Image
Image
Image Certificate included
Image About the Speaker
Image
What will you Learn?
Register Now
Image
6. 

Find the output of the following program.

public class Solution{
       public static void main(String[] args){
                     byte x = 127;
                     x++;
                     x++;
                     System.out.print(x);
       }
}
7. 

Select the valid statement.

Image Image
Start Your Coding Journey With Tracks Start Your Coding Journey With Tracks
Master Data Structures and Algorithms with our Learning Tracks
Master Data Structures and Algorithms
Image Topic Buckets
Image Mock Assessments
Image Reading Material
Image Earn a Certificate
8. 

Find the output of the following program.

public class Solution{
       public static void main(String[] args){
               int[]  x = {120, 200, 016};
               for(int i = 0; i < x.length; i++){
                        System.out.print(x[i] + “ “);
               }                   
       }
}
9. 

When an array is passed to a method, what does the method receive?

10. 

Select the valid statement to declare and initialize an array.

11. 

Find the value of A[1] after execution of the following program.

int[] A = {0,2,4,1,3};
for(int i = 0; i < A.length; i++){
A[i] = A[(A[i] + 3) % A.length];
}
12. 

Arrays in java are-

Image
Discover your path to a   Discover your path to a   Successful Tech Career for FREE! Successful Tech Career!
Image
Answer 4 simple questions & get a career plan tailored for you
Answer 4 simple questions & get a career plan tailored for you
Image Interview Process
Image CTC & Designation
Image Projects on the Job
Image Referral System
Try It Out Image
Image 2 Lakh+ Roadmaps Created
13. 

When is the object created with new keyword?

14. 

Identify the corrected definition of a package.

15. 

Identify the correct restriction on static methods.

  1. They must access only static data
  2. They can only call other static methods.
  3. They cannot refer to this or super.
16. 

Identify the keyword among the following that makes a variable belong to a class,rather than being defined for each instance of the class.

17. 

Identify what can directly access and change the value of the variable res.

package com.mypackage;
public class Solution{
       private int res = 100;
}
18. 

In which of the following is toString() method defined?

19. 

compareTo() returns

20. 

Identify the output of the following program.

String str = “abcde”;
System.out.println(str.substring(1, 3));
21. 

Identify the output of the following program.

String str = “Hellow”;
System.out.println(str.indexOf(‘t));
22. 

Identify the output of the following program.

Public class Test{
          Public static void main(String argos[]){
                   String str1 = “one”;
                   String str2 = “two”;
                   System.out.println(str1.concat(str2));
          }
}
23. 

What does the following string do to given string str1.

String str1 = “Interviewbit”.replace(‘e’,’s’);

24. 

To which of the following does the class string belong to.

25. 

How many objects will be created in the following?

String a = new String(“Interviewbit”);
String b = new String(“Interviewbit”);
Strinc c = “Interviewbit”;
String d = “Interviewbit”;
26. 

Total constructor string class have?

27. 

Find the output of the following code.

int ++a = 100;
System.out.println(++a);
28. 

Find the output of the following code.

if(1 + 1 + 1 + 1 + 1 == 5){
  System.out.print(“TRUE”);
}
else{
  System.out.print(“FALSE”);
}
29. 

Find the output of the following code.

Public class Solution{
      Public static void main(String… argos){
             Int x = 5;
             x * = (3 + 7);
             System.out.println(x);
30. 

Identify the return type of a method that does not return any value.

31. 

Output of Math.floor(3.6)?

32. 

Where does the system stores parameters and local variables whenever a method is invoked?

33. 

Identify the modifier which cannot be used for constructor.

34. 

What is the variables declared in a class for the use of all methods of the class called?

35. 

What is the implicit return type of constructor?

36. 

When is the finalize() method called?

37. 

Identify the prototype of the default constructor.

Public class Solution {}

38. 

Identify the correct way of declaring constructor.

Public class Solution {}

39. 

Find the output of the following code.

Public class Solution{
         Public static void main(String args[]){
                 Int i;
                 for(i = 1; i < 6; i++){ 
                     if(i > 3) continue;
                 }
                 System.out.println(i);
          }
}
40. 

How many times will “Interviewbit” be printed.

Int count = 0;
do{
  System.out.println(“Interviewbit”);
  count++;
} while(count < 10);
41. 

Identify the infinite loop.

42. 

What is Runnable?

43. 

Exception created by try block is caught in which block

44. 

Which of the following exception is thrown when divided by zero statement is executed?

45. 

Where is System class defined?

46. 

Identify the interface which is used to declare core methods in java?

47. 

Which of the following statements are true about finalize() method?

48. 

What does the operator >>>> do?

49. 

Identify the incorrect Java feature.

50. 

Which of the following is used to find and fix bugs in the program?

Image Excel at your interview with Masterclasses Know More
Image
Image
Image Certificate included
Image
What will you Learn?
Free Mock Assessment
Fill up the details for personalised experience.
Phone Number *
OTP will be sent to this number for verification
+1 *
+1
Change Number
Graduation Year *
Graduation Year *
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
*Enter the expected year of graduation if you're student
Current Employer
Company Name
College you graduated from
College/University Name
Job Title
Job Title
Engineering Leadership
Software Development Engineer (Backend)
Software Development Engineer (Frontend)
Software Development Engineer (Full Stack)
Data Scientist
Android Engineer
iOS Engineer
Devops Engineer
Support Engineer
Research Engineer
Engineering Intern
QA Engineer
Co-founder
SDET
Product Manager
Product Designer
Backend Architect
Program Manager
Release Engineer
Security Leadership
Database Administrator
Data Analyst
Data Engineer
Non Coder
Other
Please verify your phone number
Edit
Resend OTP
By clicking on Start Test, I agree to be contacted by Scaler in the future.
Already have an account? Log in
Free Mock Assessment
Instructions from Interviewbit
Start Test