Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

1.

You can create a variable with the same name as a reserved keyword such as "else"
- False
Public class Circle should be saved in a file called Java.exe as your source code
- False
You can have any number of classes in same file but only one can be declared as
public class
- True
Java source code is compiled to Bytecodes which then are interpreted by using JVM
or Java Virtual Machine
- True
How do you declare variable that holds text?
- String str;
How do you declare a variable that holds a character?
- char a;
What does "static" mean in main() header: public static void main(...)?
- That you don't have to create an object to execute main()
What does "void" mean in front of a method name?
- method does not return a value
How much space int and long take in RAM?
- 4 and 8 bytes
Which one in the following is a typecast?
- int a=(int)b;
how do you compare x and 5?
- If(x==5)
What datatype you would need for 3,445,456,567?
- Long
The returned value in the following method will be of which datatype? public double
getSpeed() { }
- Double
Assume you have a class Circle that models a Circle.
What parameters do you need for the following method, a member of the class?
public double getCircumference( ) { }
- None
You are given a class LeCar. How do you create an instance of this class?
- LeCar myCar=new LeCar();
What does the word reference mean in Java?
- address in RAM where an object is set
To call a regular (non-static) method you need first to _______
- create an object
What is another name for a member variable of a class?
- instance type
Member variables of a class are usually made private.
- Yes
The methods of a class are usually made public because you need to call them from
another class, such as a Tester class
- Yes
If a method does not return anything, you have to write in front of it
- Void
How do you name a public class?
- same as the file, where the class is
When you compile your Java program from command line using JAVAC the result of
the compilation is
- Bytecodes
What datatype(s) can be used to hold a real number (with a decimal point) ?
- Float
What other datatype, a longer one, is used for a real number (with a decimal point) ?
- Double
What datatype is used to hold a large whole number?
- Long
One of the popular IDE for Java is __________
- Eclipse
Java is case sensitive, Account and account are two different variables.
- True
Character literals are enclosed in ________; string literals are enclosed in ________.
- single quotes; double quotes
If x has been declared an int, which of the following statements is invalid?
- x = 1,000;
Which Scanner class method reads a String?
- next()
Which scanner class method reads an int?
- nextInt()
Which one of the following methods would you use to convert a string to a double?
- Double.parseDouble
Which of the following statements correctly creates a Scanner object
for keyboard input?
- Scanner keyboard = new Scanner (System.in);
Which of the following is not a rule that must be followed when naming
identifiers?
- Identifiers can contain spaces
Which of the following is not a primitive data type?
- String
Which of the following cannot be used as identifiers in Java?
- Key words
Which of the folloiwng does not
describe a valid comment in Java?
- Multi-line comments, start with */
and end with /*

When saving a Java source file, save it with an extension of:


- .java
What will be the value of z as a result of executing the following code?
- Z=5.0
A Boolean expression is one that is either:
- true or false
A block of code is enclosed in a set of:
- Braces { }
What is the value of x after the following code has been executed?
- 165
What will be printed when the following code is executed?
- x is unknown when the last statement is executed.
In an if/else statement, if the boolean expression is false:
- the statement or block following the else is executed
What will be the value of ans after the following code has been executed?
- 120
What will be the value of x after the following code is executed?
- 15

You might also like