Programming Final Review Flashcards

1
Q

Which of the following is a machine independent programming entity?
-Object code
-Bytecode
-Binary code
-None of the above

A

-Bytecode

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

In the following Java statement, in is
Scanner sc = new Scanner(System.in);
-It’s a Scanner type object
-an InputStream type public static field in System class.s
-a method in System class
-a System type object

A

-an InputStream type public static field in System class.s

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

Which statement is most accurate:
public class Test{
public static void main(String[] args){
double radius;
final double PI=3.15169;
double area=radiusradiusPI
System.out.println(“Area is “+area);}
}
-The code will not compile because the variable radius is not initialized
-The code compiles and runs fine
-The code has no compilation error, bit it will get a runtime error because radius is not initialized
-The code has no compilation error because a constant PI is defined inside a method

A

-The code will not compile because the variable radius is not initialized

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

Which of the following modifiers can only be used, both for a local variable/reference-variable and for a field in Java?
-public
-private
-protected
-final
-static
-abstract

A

-final

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

What does the last statement in the following code segment print if the user enters the string Hello World from the keyword?
Scanner x = new Scanner(System.in);
System.out.print(“Input a string: “);
System.out.print(new String(x.nextLine());
-Hello World
-Hello
-Nothing will be printed

A

-Hello World

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

True or False: Java assigns a default value to a data field if no value is explicitly assigned to it:
-True
-False

A

-True

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

Which of the following choices is correct for the given statement:
ClassA xa = new ClassB();
-ClassA is a derived class of ClassB
-ClassB is an implemented class of an interface called ClassA
-an abstract class ClassB is a super class of ClassA
-All of the above
-None of the above

A

-ClassB is an implemented class of an interface called ClassA

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

If a class named Student has a constructor Student (String name) defined explicitly, the following constructor is implicitly provided
-public Student()
-protected Student()
-private Student()
-Student()
-None of the above is provided

A

-None of the above is provided

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

Is the following statement true or false? Multiple inheritances can be approximated by multiple interfaces

A

-True

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

Is the following statement true or false? Any data field declared in an interface is public, static, and final by default

A

-True

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

Is the following statement true or false? Interface methods are public and abstract by default

A

-True

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

Is the following statement true or false? The constructor without a parameter can only be included in an interface declaration

A

-False

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

The method____overrides the following method in a derived class.
protected double xMethod(int x){…};
-private double xMethod(int x){…}
-protected int xMethod(double x){…}
-public double xMethod(double x){…}
-public double xMethod(int x){…}

A

-public double xMethod(int x){…}

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

Can a static method access non static data of the same class?

A

-No
-A static method cannot access any non-static data field of the same class directly without the help of the reference variable of the same class

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