JavaBasic MCQ Program Structure Data Types

0
Text Example


  Go through Java Basic Theory Notes on Program Structure 


1) Every statement in Java language should end with a?

A) Dot or Period

B) Comma

C) Semicolon

D) Colon

Answer [=]

C

2) A function in C language is similar to what in Java language?

A) Method

B) Member

C) Variable

D) None of the above

Answer [=]

A

3) All methods and variables in Java language are kept inside a?

A) File

B) Class or Interface

C) static method

D) main

Answer [=]

B

4) What is the need to mention "static" before main method?

A) To call main method without creating an object of class

B) To make main method as class method common to all instances

C) Both A and B

D) None of the above

Answer [=]

C

5) In standalone Java applications, which method is mandatory?

A) main method

B) show method

C) display method

D) print method

Answer [=]

A

Explanation:

main() is the starting point of execution.

6) What is the use of Access modifier "pubic" in Java language?

A) To hide the main method from misuse

B) To call the main method outside of Class or Package by JVM

C) To protect main method

D) None of the above

Answer [=]

B

7) Choose a Single Line Comment in Java Language below?

A)

//Some comments

B)

Some comments//

C)

/*Some comments*/

D)

*/Some comments/*

Answer [=]

A

8) Choose a multiline comment in Java language below?

A)

/*comments are going

cars are moving*/

B)

*/comments are going

cars are moving/*

C)

//comments are going

cars are moving//

D) None of the above

Answer [=]

A

9)

String args[] in main method are used for?

public static void main(String args[])

{

//

}

A) Passing arguments at compile time

B) Passing arguments at run time

C) Counting number of words

D) Nothing

Answer [=]

B

Explanation:

C:/>java Hello AFRICA GOLDMINE

Hello - Class name

AFICA - First argument

GOLDMINE - Second argument

10) What is the default return type of a method in Java language?

A) void

B) int

C) short

D) None of the above

Answer [=]

D

Explanation:

You have to explicitly mention a return type.

11) Name of a Class, Variable, Method or an Interface in Java language is called?

A) Argument

B) Value

C) Identifier

D) None of the above

Answer [=]

C

12) A valid identifier in Java language may contain which characters?

A) 0-9

B) A-Z, a-z

C) $, _ (Underscore)

D) All the above

Answer [=]

D

13) A valid Identifier or name in Java language can start with which character?

A) a-z, A-Z

B) $, _

C) 0-9

D) A and B

Answer [=]

D

Explanation:

Up to JDK 8, only a single underscore symbol can be used as an identifier of a class, method or a variable. JDK 9 does not allow.

14) What are the valid White Spaces available in Java language?

A) Space

B) Enter

C) Tab

D) All the above

Answer [=]

D

15) Choose a correct version of Java Documentation Comment?

A)

/*

comments

*/

B)

/**

comments

*/

C)

/*

comments

**/

D)

/**

comments

**/

Answer [=]

B

Explanation:

Documentation comment allows writing notes about the program. javadoc commmand on the source java file generates a HTML Java documentation with the embedded comments.





Java Basic Theory Notes on Data Types




Text Example

1) What does a Data Type in Java refers to?

A) The place where data is stored

B) The technique how data is retreived

C) The type or variety of data being handled for reading and writing

D) None of the above

Answer [=]

C

Explanation:

Integers, Real numbers, Boolean, Characters etc

2) Choose the wrong statement about Java programming?

A) Java supports unsigned integers

B) Java supports signed integers

C) Java supports signed char

D) None of the above

Answer [=]

A

Explanation:

Only C language supports unsigned integers. Java does not support.

3) Which data type among the following is an implementation of Objects or OOPs?

A) byte

B) int

C) char

D) None of the above

Answer [=]

D

Explanation:

All primitive data types are implemented in a Non-Object Oriented way.

4) What is a Primitive Data Type in Java?

A) Data type, which is implemented in an Object-oriented way.

B) Data Type which is implemented in a machine-dependent way

C) Data Type which is implemented in a non-object oriented way.

D) None of the above

Answer [=]

C

5) which among the following is not a Data Type in Java?

A) short

B) int

C) long double

D) double

Answer [=]

C

Explanation:

"long double" is present only in C language.

6) Which among the following is not a valid Data Type in Java?

A) long

B) bool

C) double

D) float

Answer [=]

B

Explanation:

It is "boolean" not "bool".

7) Which is the data type used mostly to handle streams and buffers in Java language?

A) short

B) int

C) byte

D) float

Answer [=]

C

8) Which is the data type that is not recommended for numeric applications in Java?

A) byte

B) float

C) int

D) long

Answer [=]

A

Explanation:

Size of a byte is only 8 bits. Also, any arithmetic operation produces output in int, float or double. It cannot handle more data.

9) Choose the number range for byte data type in Java?

A) -127 to +128

B) -128 to +127

C) 0 to 256

D) 0 to 255

Answer [=]

B

10) What is the size of a SHORT integer in Java?

A) 1 byte

B) 2 bytes

C) 4 bytes

D) 8 bytes

Answer [=]

B

Explanation:

Number range is -32768 and +32767.

11) What is the size of an INT integer in Java?

A) 2 bytes

B) 4 bytes

C) 6 bytes

D) 8 bytes

Answer [=]

B

Explanation:

Number range is -2147483648 and 2147483647.

12) What is the size of a LONG integer in Java?

A) 2 bytes

B) 4 bytes

C) 8 bytes

D) 16 bytes

Answer [=]

C

Explanation:

Range: -9223372036854775808 and 9223372036854775807.

13) What is the size of a FLOAT floating point number in Java?

A) 2 bytes

B) 4 bytes

C) 6 bytes

D) 8 bytes

Answer [=]

B

Explanation:

Number range is ±3.40282347E+38F

14) What is the size of a DOUBLE floating point number in Java?

A) 4 bytes

B) 6 bytes

C) 8 bytes

D) 16 bytes

Answer [=]

C

Explanation:

Number range is ±1.79769313486231570E+308.

15) What is the size of a CHAR data type constant in Java?

A) 1 byte

B) 2 bytes

C) 4 bytes

D) 6 bytes

Answer [=]

B

16) What is the size of a boolean data type constant in Java?

A) 1 bit

B) 4 bits

C) 8 bits

D) Not documented well

Answer [=]

D

Explanation:

A boolean value can hold only one bit of information. But the size of a boolean constant in memory is not defined clearly anywhere. It is machine dependent. It may be 4 bytes or so.

17) What is the IEEE standard adopted to represent Floating point numbers in Java?

A) IEEE 9000

B) IEEE 800

C) IEEE 754

D) IEEE 512

Answer [=]

C

Explanation:

IEEE stands for Institute of Electrical and Electronics Engineers. Original specifications were defined in the year 1985. The current version includes improvements or corrections done in the year 2008.

18) What is the character encoding standard used in Java language?

A) ASCII

B) Unicode

C) Hexacode

D) Bytecode

Answer [=]

C

Explanation:

Unicode takes 2 Bytes of memory to represent all characters of all languages.

19) What is the abbreviation of ASCII?

A) American Standard Characters for Information Interchange

B) Australian Standard Code for Information Interchange

C) American Standard Code for Information Interchange

D) None of the above

Answer [=]

C

Explanation:

ASCII can represent only the English Alphabets and a few special symbols.

20) Choose the right statement about Java Data types.

A) Integer data types are short, int and long

B) Real number data types are float and double

C) The character data type is char.

D) All the above

Answer [=]

D

Tags

Post a Comment

0 Comments
Post a Comment (0)
Our website uses cookies to enhance your experience. Learn More
Accept !