Quizzes Flashcards

1
Q

public stativ void main(String[] args)
The word static in the method header above means that this method is accessible and usable, even though no ___________ of the class exists

A

object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

__________ error happens when you misspelled the command word javac when compiling the program.

A

syntax

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Java was developed by ___________ to be architecturally neutral, which means it can be run on a wide variety of computer platforms.

A

Sun Microsystems

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The _______ translates language statements into machine code

A

compiler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A logic error is also called a _________ error, in which the program runs but produces an incorrect result due to a wrong procedure

A

semantic error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

javac FirstJavaProgram.java

When this command line is run, it will _________.

A

create a new file with the same filename but will a .class extension

compile a class named FirstJavaProgram into a bytecode

generates no messages if there is no syntax error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

public class FirstJavaProgram

This command line is the ____________

A

Class header

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In Java, lines comments start with two ____________.

A

forward slashes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In Java, block comments start with __________

A

a forward slash and an asterisk

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The parameter _______ means that the method does not return a value.

A

void

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Java source code is always written in __________

A

high-level language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Declaring a method ________ will allow methods in other classes to access or call it

A

public

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Apart from line and block comments, Java also supports another type of comment called _________ for generating documentation.

A

javadocs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

public class FirstJavaProgram

{

public static void main()

{

}

}

The way the text above is written in Java programming is called:

A

Allman Style

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which of the following is the correct way of assigning a value to a variable?

int studentPopulation = 44;
char myGender = F;

A

int studentPopulation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How many relational operators does Java support?

A

6 (<, >, ==, <=, >=, !=)

17
Q

Which type of variable is declared inside a method and is only accessible within that method?

A

local variable

18
Q

Where is an instance variable declared?

A

Outside any method, but inside a class

19
Q

What is a class variable?

A

A variable declared inside a class but outside any method

20
Q

Which type of variable is marked with the static keyword?

A

class variable

21
Q

What is the size of the int data type in Java?

A

32 bits

22
Q

Which data type is used for single-precision floating-point numbers in Java?

A

float

23
Q

What is the range of the char data type in Java?

A

unicode characters

24
Q

Which data type is used to represent true or false values in Java?

A

boolean

25
Q

What is the missing operator that will check if a given grade is higher or lower than the specified limits:

if (prelimGrade < LOW _____ prelimGrade > HIGH)

A

II

26
Q

A switch statement is useful when you need to test a single variable against a series of exact ______ values.

A

integer/character/string

27
Q

Which is a primitive data type in Java?

A

boolean
integer
char

28
Q

Assuming a variable k has been initialized to 23, which of the following statements sets m to 32?

A

if (k != 30 || k == 23) m = 32;

29
Q

What are the different types of if statement?

A

single-alternative
dual-alternative
nested