Java Programming Fundamentals
Test your knowledge of Java language syntax, array declarations, abstract classes, interfaces, and object-oriented programming concepts.
Questions
What are the two parts of a value of type double?
- significant digits
- length
- numerator
- denominator
After the following code fragment, what is the value in a?String s;int a;s = "Foolish boy.";a = s.indexOf("fool");
- -1
- 0
- 4
- 8
What is the value of k after the following code fragment? int k = 0; int n = 12 while (k < n) { k = k + 1; }
- O
- 11
- 12
- -3
Given the following code fragment:int A[];int i = 0;A = new int A[4];while (i < 4){A[i] = 10;i = i + 1;}
- 0
- 3
- 10
- UNKNOWN
Given the following statement:huey.setDouble(8.0*32.2+1.0);What must be the data type of huey?
- DoubleField
- TextField
- IntField
- double
The method setLabel can be used with what type of Object?
- DoubleField
- int
- TextField
- String
A function is:
- An entity that receives inputs and outputs
- A way of storing values
- A sequence of characters enclosed by quotes
- A kind of computer
A signed data type has an equal number of non-zero positive and negative values available.TRUE/FALSE ?
- True
- False
class C1 { static interface I { static class C2 { } } public static void main(String a[]) { C1.I.C2 ob1=new C1.I.C2(); System.out.println("object created"); } } What is the result of attempting to compile and run the program?
- prints object created
- Compile time error
- Runtime Excepion
- None of the above
class C1 { static class C2 { static int i1; } public static void main(String a[]) { System.out.println(C1.C2.i1); } } What is the result of attempting to compile and run the program?
- prints 0
- Compile time error
- Runtime exception
- None of the above
Which declare a compilable abstract class? (Choose all that apply.)
- A. public abstract class Canine { public Bark speak(); }
- B. public abstract class Canine { public Bark speak() { } }
- C. public class Canine { public abstract Bark speak(); }
- D. public class Canine abstract { public abstract Bark speak(); }
Which are legal declarations?
- short x [];
- short [] y;
- short [5] x2;
- short z2 [5];
- short [] z [] [];
- short [] y2 = [5];
Which is true? (Choose all that apply. )
- A. "X extends Y" is correct if and only if X is a class and Y is an interface
- B. "X extends Y" is correct if and only if X is an interface and Y is a class
- C. "X extends Y" is correct if X and Y are either both classes or both interfaces
- D. "X extends Y" is correct for all combinations of X and Y being classes and/or interfaces
Given: 1. class Voop { 2. public static void main(String [] args) { 3. doStuff(1); 4. doStuff(1, 2); 5. } 6. // insert code here 7. } Which, inserted independently at line 6, will compile? (Choose all that apply.)
- static void doStuff(int... doArgs) { }
- static void doStuff (int [] doArgs) { }
- static void doStuff(int doArgs...) { }
- static void doStuff(int... doArgs, int y) { }
- static void doStuff(int x, int... doArgs) { }
Given the following, 1. interface Base { 2. boolean m1 (); 3. byte m2(short s); 4. } Which code fragments will compile? (Choose all that apply.)
- interface Base2 implements Base { }
- abstract class Class2 extends Base { public boolean ml() { return true; } }
- abstract class Class2 implements Base { }
- abstract class Class2. implements Base { public boolean m1() { return (true); } }
- class Class2 implements Base { boolean m1( ) { return false; } byte m2(short s) { return 42; } }
Which declare a compilable abstract class? (Choose all that apply.)
- public abstract class Canine { public Bark speak(); }
- public abstract class Canine { public Bark speak() { } }
- public class Canine { public abstract Bark speak(); }
- public class Canine abstract { public abstract Bark speak(); }
Which is true? (Choose all that apply. )
- "X extends Y" is correct if and only if X is a class and Y is an interface.
- "X extends Y" is correct if and only if X is an interface and Y is a class.
- "X extends Y" is correct if X and Y are either both classes or both interfaces.
- "X extends Y" is correct for all combinations of X and Y being classes and/or interfaces.
Given: 1. class Voop { 2. public static void main(String [] args) { 3. doStuff(1); 4. doStuff(1, 2); 5. } 6. // insert code here 7. } Which, inserted independently at line 6, will compile? (Choose all that apply.)
- static void doStuff(int... doArgs) { }
- static void doStuff (int [] doArgs) { }
- static void doStuff(int doArgs...) { }
- static void doStuff(int... doArgs, int y) { }
- static void doStuff(int x, int... doArgs) { }
Which are legal declarations? (Choose all that apply. )
- short x [];
- short [] y;
- short [5] x2;
- short z2 [5];
- short [] z [] [];
- short [] y2 = [5];
Can there be multiple tag in tiles-defs.xml?
- No
- Yes
- always present
- None of the above