Programming MCQs

MCQ Questions on Java With Answer set-7

Pinterest LinkedIn Tumblr
This set of MCQ questions on java with answer includes the collection of multiple-choice questions on the fundamentals of java programming language with the answer. It includes MCQ questions on Java classes, packages and different flow control statements used in java along with their answer.

1. The ……………… and ……………….. classes are abstract classes that support reading and writing of byte streams.
A) reader, writer
B) inputstream, outputstream
C) objectinputstream, objectoutputstream
D) none

2. What is the error in the following code?

 class Test
     {
         abstract void display( );
     }

A) No error
B) Method display( ) should be declared as static
C) Test class should be declared as abstract
D) Test class should be declared as public

3. A package is a collection of
A) classes
B) interfaces
C) editing tools
D) classes and interfaces

4. Which of the following methods belong to the string class?
A) length( )
B) compare To ( )
C) equals ( )
D) All of them

5. What will be the output of the following code?

byte x=64, y;
    y= (byte) (x<<2);
    System.out.println(y);

A) 0
B) 1
C) 2
D) 64

Read Also: Quitz Questions on Java with Answers

6. If m and n are int type variables, what will be the result of the expression

m%n
    when m=5 and n=2 ?

A) 0
B) 1
C) 2
D) None of the above

7. Which of the following control expressions are valid for an if statement?
A) An integer expression
B) A Boolean expression
C) Either A or B
D) Neither A nor B

8. The concept of multiple inheritance is implemented in Java by
A) extending two or more classes
B) extending one class and implementing one or more interfaces
C) implementing two or more interfaces
D) both B and C

9. Which of the following do not represent legal flow control statements?
A) break;
B) return;
C) exit();
D) continue outer;

10. Data input is
A) an abstract class defined in java.io
B) a class we can use to read primitive data types
C) an interface that defines methods to open files.
D) an interface that defines methods to read primitive data types.

Answers:

1.  B) inputstream, outputstream
2.  C) Test class should be declared as abstract
3.  D) classes and interfaces
4.  D) All of them 
5.  A) 0
6.  B) 1
7.  B) A Boolean expression
8.  D) both B and C
9.  C) exit();
10.D) an interface that defines methods to read primitive data types.

Read Next: Java Multiple Choice Questions With Answers set-8
Read More: Collection of Java MCQ Questions and Answers

Please follow and like us:
RSS
Follow by Email
X (Twitter)
Visit Us
Follow Me
YouTube
YouTube
LinkedIn
linkedIn | MCQ Questions on Java With Answer set-7
Share

Author

Shuseel Baral is a web programmer and the founder of InfoTechSite has over 8 years of experience in software development, internet, SEO, blogging and marketing digital products and services is passionate about exceeding your expectations.

Comments are closed.

RSS
Follow by Email
X (Twitter)
Visit Us
Follow Me
YouTube
YouTube
LinkedIn
Share