Quizzes Flashcards
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
object
__________ error happens when you misspelled the command word javac when compiling the program.
syntax
Java was developed by ___________ to be architecturally neutral, which means it can be run on a wide variety of computer platforms.
Sun Microsystems
The _______ translates language statements into machine code
compiler
A logic error is also called a _________ error, in which the program runs but produces an incorrect result due to a wrong procedure
semantic error
javac FirstJavaProgram.java
When this command line is run, it will _________.
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
public class FirstJavaProgram
This command line is the ____________
Class header
In Java, lines comments start with two ____________.
forward slashes
In Java, block comments start with __________
a forward slash and an asterisk
The parameter _______ means that the method does not return a value.
void
Java source code is always written in __________
high-level language
Declaring a method ________ will allow methods in other classes to access or call it
public
Apart from line and block comments, Java also supports another type of comment called _________ for generating documentation.
javadocs
public class FirstJavaProgram
{
public static void main()
{
}
}
The way the text above is written in Java programming is called:
Allman Style
Which of the following is the correct way of assigning a value to a variable?
int studentPopulation = 44;
char myGender = F;
int studentPopulation
How many relational operators does Java support?
6 (<, >, ==, <=, >=, !=)
Which type of variable is declared inside a method and is only accessible within that method?
local variable
Where is an instance variable declared?
Outside any method, but inside a class
What is a class variable?
A variable declared inside a class but outside any method
Which type of variable is marked with the static keyword?
class variable
What is the size of the int
data type in Java?
32 bits
Which data type is used for single-precision floating-point numbers in Java?
float
What is the range of the char
data type in Java?
unicode characters
Which data type is used to represent true or false values in Java?
boolean
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)
II
A switch statement is useful when you need to test a single variable against a series of exact ______ values.
integer/character/string
Which is a primitive data type in Java?
boolean
integer
char
Assuming a variable k has been initialized to 23, which of the following statements sets m to 32?
if (k != 30 || k == 23) m = 32;
What are the different types of if statement?
single-alternative
dual-alternative
nested