Sei sulla pagina 1di 33

What's the extension for a compiled Java file?

A. .class

B. .java

C. .xml

7. What's the common term for an error within a computer program's code that prevents it from
functioning properly?

A. A glitch

B. A hack

C. A bug

Object-Oriented Programming means ...

Discuss

A.

Being objective about what you develop

B.

Designing the application based on the objects discovered when analysing the problem

C.

Writing an algorithm before writing your program and having a test plan

D.

Writing a program composed of Java classes

2.

If none of the private/protected/public is specified for a member, that member ...

A.

Is accessible publicly
B.

Is only accessible by other classes of the same package

C.

Is only accessible from within the class

D.

Is accessible by the class and its subclasses

3.

Which one is not correct?

Discuss

A.

A class needs to be instantiated as an object before being used

B.

An objects exists in memory in run time

C.

Class and object are just different names for the same thing

D.

An object is a variable, where its type is the class used to declare the variable

4.

Which is not a part of defining an object?

A.

Description
B.

Methods

C.

Associations with other objects

D.

Name

5.

Class B inherits from Class A, what cannot be said:

A.

B is a sub-class of A

B.

A is a super-class of B

C.

B has access to private members of A

D.

B has access to protected members of A

6.

What is a member of a class

A.

An attribute

B.
A method

C.

Attribute or method

D.

A sub-class

An object could be ...

A.

Anything

B.

An algorithm

C.

A data container

D.

A program

10.

A class is...

A.

An object

B.

An executable piece of code


C.

An abstract definition of an object

D.

A variable

The last value in an array called ar can be found at index:

A.

B.

C.

Ar.length

D.

Ar.length - 1

22.

What would display from the following statements? int [ ] nums = {1,2,3,4,5,6};
System.out.println((nums[1] + nums[3]));

A.

B.

2+4

C.
1+3

D.

23.

What loop will display each of the numbers in this array on a separate line: float [ ] nums= {1.1f, 2.2f,
3.3f};

A.

For (int i =0; i < 3; i++) System.out.println( nums[i]);

B.

For (i = 1; i

C.

For (i = 0; i

D.

For (i = 1; i < 3; i++) System.out.println(nums[i]);

24.

What displays from the following statements? String word = "abcde"; for (int i = 0; i <4; i+=2)
System.out.print(word[i]);

Discuss

A.

Ab

B.

Ac
C.

Ace

D.

Bd

25.

Given the declaration : int [ ] ar = {1,2,3,4,5}; What is the value of ar[3]?

Discuss

A.

B.

C.

D.

26.

Given the declaration : int [ ] ar = {1,2,3,4,5}; What is the value of ar[4]?

A.

B.

3
C.

D.

27.

Given the declaration int [ ] nums = {8, 12, 23, 4, 15}, what expression will display the first element in the
array (ie the number 8)

A.

System.out.print("The number is : " + nums[0]);

B.

System.out.print("The number is : " + nums[1]);

C.

System.out.print("The number is : " + nums[8]);

D.

System.out.print("The number is : " + nums);

28.

An array holds:

Discuss

A.

Similar values of same data type

B.
Different values of same data type

C.

Same values of different data types

D.

Different values of different data types

29.

The range of indices for an array always start at:

A.

Whatever programmer specifies

B.

C.

D.

Size of array

30.

The most common use of an array is to:

Discuss

A.

Perform for loop on array

B.
Perform different operations on each element in array

C.

Perform the same operation on all elements in array

D.

Perform while loop on array

31.

If we declare int [ ] ar = {1,2,3,4,5,6}; The size of array ar is:

A.

B.

C.

D.

38.

Choose the appropriate data type for this value: "volatile"

Discuss

A.

Int

B.
String

C.

Double

D.

Boolean

39.

Choose the appropriate data type for this value: true

A.

Int

B.

Double

C.

String

D.

Boolean

40.

Choose the appropriate data type for this value: 1

A.

Int

B.

Double
C.

String

D.

Boolean

41.

Choose the appropriate data type for this value: 5.5

A.

Int

B.

Double

C.

Boolean

D.

String

42.

Choose the appropriate data type for this value: A

A.

Int

B.

Double
C.

Char

D.

String

43.

Choose the appropriate data type for this value: "1"

Discuss

A.

String

B.

Boolean

C.

Int

D.

Char

44.

Choose the appropriate data type for this value: female

A.

Boolean

B.

Int
C.

Char

D.

Double

45.

Choose the appropriate data type for this field: kindOfBird

A.

String

B.

Int

C.

Char

D.

Double

46.

Choose the appropriate data type for this field: numberOfEggs

Discuss

A.

Double

B.

Char
C.

Boolean

D.

Int

47.

Choose the appropriate data type for this field: weightInKilos

A.

Char

B.

String

C.

Double

D.

Boolean

48.

Choose the appropriate data type for this field: isSwimmer

A.

Double

B.

Boolean

C.
String

D.

Int

49.

Which of the following always need a Capital letter ?

A.

Class names and Strings

B.

Objects and class names

C.

Fields and Strings

D.

Data types and fields

What is the keyword used in java to create an object?

A.

This

B.

New

C.

Sync
D.

New()

75.

What is the correct syntax for java main method?

Discuss

A.

Public void main(String[] args)

B.

Public static void main(string[] args)

C.

Public static void main()

D.

None of the above

Java runs on _______.

A.

Windows

B.

Unix/Linux

C.

Mac
D.

All of the Above

What is the main function of any variable ?

A.

To add numbers together

B.

To keep track of data in the memory of the computer

C.

To print words on the screen

D.

To write Java codes

83.

What is the proper way to declare a variable ?

A.

VariableName variableType;

B.

VariableName;

C.

VariableType;

D.
VariableType variableName;

84.

What is an assignment statement ?

A.

Adding a number to an int

B.

Assigning a multiplication

C.

Assigning a name to a variable

D.

Assigning a value to a variable

85.

What will be the value of “num” after the following statements? int num; num = (5+4); num = num / 9;
num = 9;

A.

B.

C.

D.
Num

86.

If you want your conditional to depend on two conditions BOTH being true, what is the proper notation
to put between the two Boolean statements ?

A.

&

B.

&&

C.

D.

||

87.

Which of the following means that in order for the conditional to happen, either x must be less than 3 or
y must be greater than or equal to 4 ?

A.

If ((x < 3) && (y > 4))

B.

If (x < 3 y >= 4)

C.

If ((x < 3) || (y > = 4))


D.

If ((x > 3) || (y < = 4))

88.

What is a loop ?

A.

A new type of Applet.

B.

A segment of code to be run a specified amount of times

C.

A segment of code to be run infinite times

D.

A segment of code to be run once

Which is NOT a section of all types of loops ?

A.

Initialization

B.

Loop Body

C.

Test statement

D.
The word "while"

91.

In a ‘for’ loop, what section of the loop is not included in the parentheses after “for” ?

A.

Initialization

B.

Loop Body

C.

Test statement

D.

Update

92.

What is the difference between private and public functions ?

Discuss

A.

Public functions are free, you have to buy private ones

B.

Public functions are the only ones you can download

C.

Public functions can be used by anyone, private can only be used by other code in the class you are
writing
D.

Public functions can’t be used

Which of the following individuals is credited for first designing Java?

Tim Ritchey
James Gosling
Jim LeValley
Ian Sheeler

Which company now owns Java?

Apache Software Foundation


Oracle Corporation
SAP
PeopleSoft Inc.

What will the output be of this expression if the variable x = 13?

'The number was too low' x = 13


x < 12 Nothing will happen.

The Java if statement:

Evaluates whether an expression is equal or not


Evaluates whether an expression is true or false

Evaluates whether an expression is less than or more than a number

Evaluates whether a String object contains certain letters or not

How will you describe Java?


A.
Programming Language

B.
Platform

C.
Both Programming Language and Platform

D.
Abstract Machine

2.
Java Is Structured Programming Language.
Discuss
A.
True

B.
False
3.
Which of the following are legal identifiers in Java?
Discuss
A.
1abc

B.
Abc_1

C.
OneAbc

D.
Final

E.
$while

5.
Which of the following is a correct declaration of variable in Java ?
A.
Int num

B.
Int-num

C.
Int num;

D.
Int-num;

6.
Which of the following is a correct variable initialization in Java ?
A.
Int num = 10

B.
Int-num = 10

C.
Int num = 10;

D.
Int-num = 10

7.
What is the default value of the data type byte in Java ?
A.
0

B.
Null

C.
1
D.
None of the above

8.
What is the default value of the data type int in Java ?
A.
1

B.
0

C.
0i

D.
None of the above

9.
What is the default value of the data type long in Java ?
A.
0

B.
1

C.
0L

D.
10
One of the following is regarded as one of the most powerful basic data structures?
A.
Array

B.
Tree

C.
Stack

D.
Queue

2.
A string can be referred to as a sequence of
A.
Numbers

B.
Characters

C.
Letters

D.
All of the above
3.
JDBC is an acronym of
A.
Java Database Connectivity

B.
Joint Development Control

C.
Joint Database Connection

D.
Java Database Code

4.
One of the following is not true about threads
A.
Threads exists as a subset of a process

B.
Multiple threads can exist within one process, executing concurrently

C.
Threads have separate address spaces

D.
Systems with a single processor generally do not implement multithreading

5.
Who designed Java?
A.
Mike Sheridan

B.
Patrick Naughton

C.
Brendan Eich

D.
James Gosling

6.
Java was initially called
A.
Gosl

B.
Green

C.
Jave

D.
Oak

7.
Java can be said to be
A.
Concurrent
B.
Class-based

C.
Object-oriented

D.
All of the above

8.
The latest Java version of java was released on
A.
October 22, 2017

B.
September 21, 2017

C.
Decembe 11, 2017

D.
March 21, 2017

9.
The following were the primary goals of the java language except
A.
It must be stringed, coded, and encrypted

B.
It must be simple, object-oriented, and familiar

C.
It must be architecture-neutral and portable

D.
It must be interpreted, threaded, and dynamic

10.
In Java, programs are compiled into
A.
Java source code

B.
Pseudo code

C.
Bytecode

D.
Machine code

11.
In order for Java programs to be executed, it must be compiled how many times?
A.
Twice

B.
Once
C.
Thrice

D.
None of these

Potrebbero piacerti anche