Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Mock Exam 3 Answers

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

1. Which of the following statements is correct?

Select 1 option(s):
A. new, delete, and goto are keywords in the Java language delete & exit is method, throws
B. try, catch, and thrown are keywords in the Java language not thrown, unsigned is wrong
C. static, unsigned, and long are keywords in the Java language
D. exit, class, and while are keywords in the Java language
E. return, goto, and default are keywords in the Java language

2. What can be inserted in the following code so that it will print true when run?

List s1 = new ArrayList( );


s1.add("ann");
s1.add("bella");

//INSERT CODE HERE

System.out.println(flag);
Select 1 option(s):
A. boolean flag = s1.contains("bella"); indexOf() to check index of " "
contains() check is the list contains " "
B. boolean flag = s1.indexOf("bella")>1; length() for array, list uses size()
C. boolean flag = s1.contains("bella") == 1;
D. boolean flag = s1.length()>1;

3. What will the following code print?


int x = 1; x > a? (y > b? y:b)(x > z? x:z)
int y = 2; (true) (false)
int z = x++; z = x++ = 1
int a = --y; x=2
int b = z--; a = --y = 1
b += ++z; y=1
b = z-- = 1
int answ = x>a?y>b?y:b:x>z?x:z; b = b + ++z
System.out.println(answ); = 1 + ++0
Select 1 option(s): =1+1
A. 0 b=2
B. 1 y>b
2 > 2 wrong so print b
C. 2
D. -1
E. -2
F. 3
To store primitives in ArrayList must use
objects, thats why ArrayList<Integer> not
4. Identify the correct statements about ArrayList. ArrayList<int>
Select 3 option(s):
A. Standard JDK provides no subclasses of ArrayList.
B. An ArrayList cannot store primitives.
C. It allows constant time access to all its elements.
D. ArrayList cannot resize dynamically if you add more number of elements than its
capacity.
E. An ArrayList is backed by an array. ??
F. Elements can be inserted into an ArrayList at various positions using the assignment
operator.

5. What will the following code print when compiled and run?

public class Account {


double balance;
public void update(int[] balances){
for(int bal : balances){
bal = 100;
bal in update() is different dengan bal
}
dalam main()
}

public static void main(String[] args) {


int[] balances = new int[2];
balances[0] = 10;
balances[1] = 20;
for(int bal : balances){
System.out.print(bal+" ");
}
Account a = new Account();
a.update(balances);
for(int bal : balances){
System.out.print(bal+" ");
}
}
}
Select 1 option(s):
A. 10 20 100 100
B. 10 20 10 20
C. Compilation failure
D. An exception will be thrown at run time.
6. Given a class named Test, which of these would be valid definitions for the
constructors for the class?
Select 1 option(s):
If takde public pun takpe for constructor
A. Test(Test b) { }
Test Test() salah bcs guna nama class 2 times
B. Test Test( ) { }
Constructor cannot be final and void
C. private final Test( ) { }
D. void Test( ) { }
E. public static void Test(String args[ ] ) { }

7. What will the following code print?

public class TestClass


{
int x = 5;
int getX(){ return x; }

public static void main(String args[]) throws


Exception
{
TestClass tc = new TestClass();
tc.looper();
System.out.println(tc.x);
}

public void looper()


{
int x = 0; if comment out yg ni x semua akan ambik yg object field so it will print 0 sbb dah set x = m
while( (x = getX()) != 0 ) x yg ni ambik yg object field atas yg int x = 5
{
for(int m = 10; m>=0; m--)
{
x = m; x yg ni ambik yg local yg int x = 0;
}
}

}
Select 1 option(s):
A. It will not compile.
B. It will throw an exception at runtime.
C. It will print 0.
D. It will print 5.
E. None of these.
8. What will the following lines of code print?
String s = "java";
s.replace('j', 'l'); replace but tak set kat s that's why dia ambik yg java, s = s.replace('j', 'l') baru tukar lava
s = s.substring(0, 2);
System.out.println(s);
Select 1 option(s):
A. java
B. lava
C. la
D. ja
E. lav

9. What will be printed when the following code snippet is executed?

String str = "123456789";


String s = str.substring(2, 5);
System.out.println(s);
Select 1 option(s):
A. 23456
B. 345678
C. 45678
D. 2345
E. 3456
F. 345

10. Following is not a valid comment:


/* this comment /* // /** is not valid */
Select 1 option(s):
A. True
B. False

11. What what will the following statement:


" hello java guru ".trim();
return ?
Select 1 option(s):
A. The line of code will not Compile.
B. "hellojavaguru" trim() method eliminate spaces infront and behind only,
will not trim spaces in between/middle spaces
C. "hello java guru"
D. "hello java guru "
E. None of the above.
12. Given the following code, which method declarations can be inserted at line 1 without
any problems?

public class OverloadTest


{
public int sum(int i1, int i2) { return i1 + i2; }
// 1
} A and E wrong because same name and same parameter numbers and type
Select 3 option(s):
A. public int sum(int a, int b) { return a + b; }
B. public int sum(long i1, long i2) { return (int) i1; }
C. public int sum(int i1, long i2) { return (int) i2; }
D. public long sum(long i1, int i2) { return i1 + i2; }
E. public long sum(int i1, int i2) { return i1 + i2; }

13. Identify correct statements:


Select 1 option(s):
A. Java development environment requires an IDE to be installed before the JDK.
B. Java development environment is installed by default for all major operating
systems.
C. Java development environment requires you to install the JRE first.
D. Java development environment is set up when you download an install the JDK for
your platform.
E. Both JDK and JRE are required for setting up the Java development environment.
F. Java development environment is the combination of JDK, JRE, and IDE

14. What will be the output of the following class...

class Test
{
public static void main(String[] args)
{
int j = 1; doIt() throw exception so dia catch and print la "j = " + j, j is initialize
try as 1 so it'll print j = 1;
If ada finally, finally will be printed gak
{ 1. buat doIt()
int i = doIt() / (j = 2);
} catch (Exception e)
{ 3. catch exception, so buat la yg syso j =
System.out.println(" j = " + j);
}
} 2. throw exception
public static int doIt() throws Exception { throw new
Exception("FORGET IT"); }
}
Select 1 option(s):
A. It will print j = 1;
B. It will print j = 2;
C. The value of j cannot be determined.
D. It will not compile.
E. None of the above.

15. Which of the following is illegal ?


Select 1 option(s):
A. char c = 320;
B. float f = 320;
C. double d = 320;
D. byte b = 320; -128 until 127
E. None of the above is illegal.

16. What will the following program print?

public class TestClass


{
public static void main(String[] args)
{
for : for(int i = 0; i< 10; i++)
{
for (int j = 0; j< 10; j++)
{
if ( i+ j > 10 ) break for; for is RESERVED WORD!!!!!!!!
}
System.out.println( "hello");
}
}
}
Select 1 option(s):
A. It will print "hello" 6 times.
B. It will not compile.
C. It will print "hello" 2 times.
D. It will print "hello" 5 times.
E. It will print "hello" 4 times.
17. What would be the result of attempting to compile and run the following program?

class TestClass
{
static TestClass ref; Create object class
String[] arguments;
public static void main(String args[])
{
ref = new TestClass();
ref.func(args); syso ref akan print class name, package and memory
}
public void func(String[] args)
{
ref.arguments = args;
}
}
Select 1 option(s):
A. The program will fail to compile, since the static method main is trying to call the
non-static method func.
B. The program will fail to compile, since the non-static method func cannot access the
static member variable ref.
C. The program will fail to compile, since the argument args passed to the static
method main cannot be passed on to the non-static method func.
D. The program will fail to compile, since method func is trying to assign to the non-
static member variable 'arguments' through the static member variable ref.
E. The program will compile and run successfully.

18. Which of the following statements about an array are correct?


Select 1 option(s):
A. An array can dynamically grow in size. Array size is fixed
B. Arrays can be created only for primitive types. Array can put primitive and primitive
C. Every array has a built in property named 'size' which tells you the number of
elements in the array. Array uses length(), list uses size()
D. Every array has an implicit method named 'length' which tells you the number of
elements in the array.
E. Element indexing for arrays as well as for Lists starts at 0.
19. Which class definition uses the naming conventions of Java Programming?
Select 1 option(s):
A. class coursemanagement{
String course_ID;
final int PASSING_MARKS = 50;
public void enrollStudents(){ }
}
B. class CourseManagement{
String courseID;
final int PASSING_MARKS = 50;
public void EnrollStudents(){ }
}
C. class CourseManagement{
String str_course_id;
final int INT_PASSING_MARKS = 50;
public void EnrollStudents(){ }
}
D. class CourseManagement{
String courseID;
final int CONST_PASSING_MARKS = 50;
public void enrollStudents(){ }
}
E. class CourseManagement{ package use small letters, class PascalCase
String courseId;
final int PASSING_MARKS = 50;
public void enrollStudents(){ }
}
F. class courseManagement{
String courseId;
final int PASSING_MARKS = 50;
public void enrollStudents(){ }
}
20. Given the following code, which of these statements are true?
public class TestClass
{
public static void main(String args[])
{
int k = 0;
int m = 0;
for ( int i = 0; i <= 3; i++)
{
k++;
if ( i == 2)
{
// line 1
}
m++;
}
System.out.println( k + ", " + m );
}
}
Select 3 option(s):
A. It will print 3, 2 when line 1 is replaced by break;
B. It will print 3, 2 when line 1 is replaced by continue.
C. It will print 4, 3 when line 1 is replaced by continue.
D. It will print 4, 4 when line 1 is replaced by i = m++;
E. It will print 3, 3 when line 1 is replaced by i = 4;

21. What will the following method return if called with an argument of 7?

public int transformNumber(int n)


{
int radix = 2;
int output = 0;
output += radix*n;
radix = output/radix;
if(output<14)
{
return output;
}
else
{
output = output*radix/2;
return output;
}
else
{
return output/2;
}

}
Select 1 option(s):
A. 7
B. 14 else 2 kali
C. 49
D. Compilation fails.

22. How many times will the line marked //1 be called in the following code?

int x = 10;
do
{
x--;
System.out.println(x); // 1
} while(x<10);
Select 1 option(s):
A. 0
B. 1 x-- will always be < 10 so while will be always true, so line will always be called
C. 9
D. 10
E. None of these.

23. Which of the following implementations of a max() method will correctly return the
largest value?
Select 1 option(s):
A. int max(int x, int y) A and B return statement invalid syntax
C sbb ada condition dlm switch
{
return( if(x > y){ x; } else{ y; } );
}
B. int max(int x, int y)
{
return( if(x > y){ return x; } else{ return y; } );
}
C. int max(int x, int y)
{
switch(x < y) cannot put condition in switch, letak variable je nanti dia tengok
{ variable tu pass apa
case true:
return y;
default :
return x;
};
}
D. int max(int x, int y)
{
if (x > y) return x;
return y;
}
24. What will the following program print?

public class TestClass


{
static String str;
public static void main(String[] args)
{
System.out.println(str);
}
}
Select 1 option(s):
A. It will not compile.
B. It will compile but throw an exception at runtime.
C. It will print 'null' default value for string is null
D. It will print nothing.
E. None of the above.

25. Consider the following code:


String[] dataList = {"x", "y", "z"};
for (String dataElement : dataList) {
int innerCounter = 0;
while (innerCounter < dataList.length) {
System.out.println(dataElement + ", " + innerCounter);
innerCounter++;
}
}
How many times will the output contain 2?
Select 1 option(s):
A. 0
B. 1
C. 2
D. 3 Theres 2 loop so it'll print x1 x2 x3 y1 y2 y3 z1 z2 z3, 2 will be in the
output 3 times
E. 4
F. It will fail to compile.
26. What will the following program print?

public class TestClass


{
public static void main(String[] args)
{
Object obj1 = new Object();
Object obj2 = obj1;
if( obj1.equals(obj2) ) System.out.println("true");
else System.out.println("false");
}
}
Select 1 option(s):
A. true obj1 will get the address of obj2, equals will compare the address
B. false
C. It will not compile.
D. It will compile but throw an exception at run time.
E. None of the above.

27. Using a break in a while loop causes the loop to break the current iteration and start
the next iteration of the loop.
Select 1 option(s):
A. True
B. False break will stop the whole loop, not the current iteration only

28. Which of the following statements will correctly create and initialize an array of Strings
to non null elements?
Select 4 option(s):
A. String[] sA = new String[1] { "aaa"}; cannot assign size terus
B. String[] sA = new String[] { "aaa"};
C. String[] sA = new String[1] ; sA[0] = "aaa";
D. String[] sA = {new String( "aaa")};
E. String[] sA = { "aaa"};
29. What will be the output of the following program?

public class TestClass


{
public static void main(String[] args) throws Exception
{
try{
amethod();
System.out.println("try");
}
catch(Exception e){
System.out.println("catch");
}
finally {
System.out.println("finally");
}
System.out.println("out");
}

public static void amethod(){ } if method kosong pun boleh je as long as dia void
}
Select 1 option(s):
A. try finally
B. try finally out
C. try out
D. catch finally out
E. It will not compile because amethod() does not throw any exception.

30. Which of the following code snippets will print exactly 10?

1.
Object t = new Integer(106);
int k = ((Integer) t).intValue()/10;
System.out.println(k);

2. System.out.println(100/9.9);
2 and 3 will print in decimal point
3. System.out.println(100/10.0);

4. System.out.println(100/10);

5. System.out.println(3 + 100/10*2-13);
Select 3 option(s):
A. 1
B. 2
C. 3
D. 4
E. 5
31. What is the result of compiling and running the following program?

public class Learner {


public static void main(String[] args) {
String[] dataArr = new String[4];
dataArr[1] = "Bill";
dataArr[2] = "Steve";
dataArr[3] = "Larry";
try{
for(String data : dataArr){
System.out.print(data+" ");
}
}catch(Exception e){
System.out.println(e.getClass());
}
}
}
Select 1 option(s):
A. Bill Steve Larry null
B. Bill Steve Larry class java.lang.NullPointerException
C. class java.lang.Exception Bill Steve Larry
D. Bill Steve Larry class java.lang.Exception
E. null Bill Steve Larry index 0 take string default value which is null

32. Given the following code:


class References
{
String s1;
String s2 = null;
Integer i1 = new Integer();
int i2; int bukan object so i2 is variable je bukan object reference
File f;
Object b = f;
}
How many object references are bring created?
Select 1 option(s):
A. 3
B. 4
C. 5
D. 6
E. 7
F. 8
33. What will the following code snippet print when run?

String str = "asdfasdf"; remove() will remove the first alphabet found, but replace() will replace
char ch = str.charAt(3); all bcs remove() returns boolean and replace() returns string
if(ch == 'a') str = str.replace('a', 'x');
else if(ch == 'f') str = str.replace('s', 'x');
System.out.println(str);
Select 1 option(s):
A. asdfasdf
B. axdfaxdf
C. axdfasdf
D. xsdfxsdf
E. xsdfasdf

34. What will the following code print when compiled and run?
import java.util.*;
public class TestClass {
public static void main(String[] args) throws Exception {
List list = new ArrayList();
list.add("val1"); //1 arraylist elements need to be added in turn following the
list.add(2, "val2"); //2 next index
list.add(1, "val3"); //3 val1 is added into index 0, so val2 can only be added
System.out.println(list); into index 1
}
}
Select 1 option(s):
A. It will not compile.
B. It will throw an exception at run time because of line //1
C. It will throw an exception at run time because of line //2
D. It will throw an exception at run time because of line //3
E. Null

35. Consider the following program:

public class TestClass


{
public static void main(String[] args)
{
String tom = args[0];
String dick = args[1];
String harry = args[2];
}
}
What will the value of 'harry' if the program is run from the command line:
java TestClass 111 222 333
Select 1 option(s):
A. 111
B. 222
C. 333
D. It will throw an ArrayIndexOutOfBoundsException
E. None of the above.

36. Given the complete contents of TestClass.java file:

package x;
public class TestClass {
ArrayList<String> al;
public void init(){
al = new ArrayList<>();
al.add("Name 1");
al.add("Name 2");
}
public static void main(String[] args) throws Exception {
TestClass tc = new TestClass();
tc.init();
System.out.println("Size = "+tc.al.size());
}
}
Which import statement should be added to make it compile?
Select 1 option(s):
A. import java.lang.*;
B. import java.lang.ArrayList;
C. import java.util.ArrayList;
D. import java.collections.ArrayList;
E. No import is necessary.

37. Which of the following are benefits of ArrayList over an array?


Select 1 option(s):
A. You do not have to worry about the size of the ArrayList while appending elements.
B. It consumes less memory space.
C. You do not have to worry about thread safety.
D. It allows you to write type safe code.

38. Which of the following expressions will evaluate to true if preceded by the following
code?

String a = "java";
char[] b = { 'j', 'a', 'v', 'a' };
String c = new String(b);
String d = a;
Select 3 option(s):
A. (a == d)
B. (b == d)
C. (a == "java") same data type boleh guna ==
D. a.equals(c) diff data type kena guna equals()

39. Given that java.lang.Integer class has a public static field named MAX_VALUE,
which of the given options should be inserted at line 1 so that the following code can
compile without any errors?

package objective1;
// 1
public class StaticImports
{

public StaticImports()
{
out.println(MAX_VALUE);
}
Select 2 option(s):
A. import static java.lang.Integer.*;
B. static import java.lang.System.out;
C. static import Integer.MAX_VALUE;
D. import static java.lang.System.*;
E. static import java.lang.System.*;

40. Which of the following are true about the "default" constructor?
Select 2 option(s):
A. It is provided by the compiler only if the class does not define any constructor.
B. It initializes the instance members of the class.
C. It calls the default 'no-args' constructor of the super class.
D. It initializes instance as well as class fields of the class.
E. It is provided by the compiler if the class does not define a 'no- args' constructor.

41. Which of the following are true about Java?


Select 2 option(s):
A. It provides automatic exception handling.
B. It provides automatic memory management.
C. It provides database connectivity.
D. Java source code is converted to binary code using an interpreter.
42. What will be the output of the following program (excluding the quotes)?

public class SubstringTest


{
public static void main(String args[])
{ String is not a keyword
String String = "string isa string";
System.out.println(String.substring(3, 6));
}
}
Select 1 option(s):
A. It will not compile.
B. "ing is"
C. "ing isa"
D. "ing " (There is a space after g)
E. None of the above. substring 3,6 will take ing only

43. What will the following code print?

void crazyLoop()
{
int c = 0;
JACK: while (c < 8)
{
JILL: System.out.println(c);
if (c > 3) break JILL; else c++;
}
}
Select 1 option(s):
A. It will not compile. break is applicable to break loop only, so need to break at JACK
B. It'll throw an exception at runtime.
C. It will print numbers from 0 to 8
D. It will print numbers from 0 to 3
E. It will print numbers from 0 to 4

44. Which of the following are valid class declarations?


(Not the whole class, just the declaration).
Select 1 option(s):
A. public class Hello private
B. private class Hello implements
C. class Hello implements Listener
D. class Hello throws Exception
45. What will the following program print?

class Test
{
public static void main(String args[])
{
int var = 20, i=0;
do
{
while(true)
{
if( i++ > var) break; loop sampai i jadi 21 then break bcs 21 > 20 is true
}
}while(i<var--); 21 < 20--
System.out.println(var); 19
}
}
Select 1 option(s):
A. 19
B. 20
C. 21
D. 22
E. It'll enter an infinite loop.

46. What will the following code print when run?

public class Mambo {

public static void main(String args[]){


for(int i=0; i< 5; i++){
if(i == 2) continue;
}
System.out.println(i);
}
}
Select 1 option(s):
A. 2
B. 3
C. 4
D. 5
E. It will not compile. i is declared inside for loop so println cannot access variable i
i need to be initialize as global variable
47. Which integral types in Java have a range of 2^16 integers?
OR
Which integral types in Java can represent exactly 2^16 distinct integers?
Select 2 option(s):
A. char char and short is 16 bit, so it holds exactly 2^16
B. int int is 32 bits, long is 64 bits
C. long
D. short

48. The options below contain the complete contents of a file.


Which of these options can be run with the following command line once compiled?
java main
Select 1 option(s):
A. //in file main.java
class main { no static in main method
public void main(String[] args) {
System.out.println("hello");
}
}
B. //in file main.java no class
public static void main(String[] args) {
System.out.println("hello");
}
C. //in file main.java
public class anotherone{
}
class main {
public static void main(String[] args) {
System.out.println("hello");
}
}
D. //in file main.java
class anothermain{
public static void main(String[] args) {
System.out.println("hello2");
}
}
class main {
public final static void main(String[] args) {
System.out.println("hello");
}
}
49. Which of the following are features of Java?
Select 2 option(s):
A. It is strongly typed
B. It offers direct memory management. every variable and ex has a specific type
C. It allows multithreaded programming. java has build in support for multithreading
D. It is a distributed lanaguage.

50. Which of the following are correct about "encapsulation"?


Select 2 option(s):
A. Encapsulation is same as polymorphism.
B. It helps make sure that clients have no accidental dependence on the choice of
representation
C. It helps avoiding name clashes as internal variables are not visible outside.
D. Encapsulation makes sure that messages are sent to the right object at run time.
E. Encapsulation helps you inherit the properties of another class.

51. You have been given a library that contains the following class:
package com.cool;
public class Cooler {
public void doCool(){
System.out.println("cooling...");
}
}
Now, you are writing another class that makes use of the above library as follows:

// 1 insert code here


public class Furnace
{
public void cool(Cooler c) { // 2
c.doCool();
}
}
What should be inserted at //1 above?
Select 2 option(s):
A. package com.cool;
B. import package com.cool;
C. import com.cool.*;
D. import com.cool;
E. import class com.cool.Cooler;
F. import com.cool.Cooler;

52. What will be printed when the following code snippet is executed?

String str = "123456789";


str.substring(2, 5); tak store str.substring(2,5) so charAt(2) is still 3
System.out.println(str.charAt(2));
Select 1 option(s):
A. 3
B. 4
C. 5
D. This will not compile

53. What will the following code print when run without any arguments ...
public class TestClass {

public static int m1(int i)


{
return ++i; i is ++0 so 1
}

public static void main(String[] args) {

int k = m1(args.length); m1(0) return 1


k += 3 + ++k; k = k + 3 + ++k
System.out.println(k); k = 1 + 3 + ++1
} =1+3+2
} =6
Select 1 option(s):
A. It will throw ArrayIndexOutOfBoundsException.
B. It will throw NullPointerException.
C. 6
D. 5
E. 7
F. 2
G. None of these.

54. Given:
class Account{
//insert code here
}
What can be inserted in the above code at the specified location without causing
compilation error?
Select 1 option(s):
A. {
private String id; field declaration doesn't need curly braces
}
B. while(true) {
System.out.println("true"); takde main method
}
C. package org.acme; cannot put package in class
D. private String id = "hello";
void print(){
System.out.println(id);
} still error bcs takde main, but its runtime error not compile error
55. Given the code fragment:

int[] balances1 = new int[]{ 10, 20 };


int[] balances2 = balances1;
balances1 = new int[]{ 100 };
System.out.print(balances1 == balances2);

What is the result?


Select 1 option(s):
A. true
B. false
C. compilation failure
D. exception at run time

56. Consider the following method, which is called with an argument of 7:


public void method1(int i)
{
int j = (i*30 - 2)/100;

POINT1 : for(;j<10; j++)


{
boolean flag = false;
while(!flag)
{
if(Math.random()>0.5) break POINT1;
}
}

while(j>0)
{
System.out.println(j--);
if(j == 4) break POINT1;
}
}
What will it print?
Select 1 option(s):
A. It will print 1 and 2
B. It will print 1 to N where N is a random number.
C. It will not compile. while is a diff block of code, it cannot access POINT1
D. It will throw an exception at runtime.
57. Given:
String s1 = "Hello";
String s2 = "World";
//1
Which of the following options are valid when inserted independently at the line
marked //1?
Select 3 option(s):
A. s1 += s2;
B. s1 -= s2;
C. System.out.println( s1 = s2 );
D. System.out.println( s1 == s2);

58. What will be the result of attempting to compile the following program?
public class TestClass
{ this is a method not constructor bcs
long l1; there's void
public void TestClass(long pLong) { l1 = pLong ; } //1
public static void main(String args[])
{
TestClass a, b ;
a = new TestClass(); //2
b = new TestClass(5); //3 no constructor created for this class, so 5 cannot
} be passed as parameter
}
Select 1 option(s):
A. A compilation error will be encountered at //1, since constructors should not specify
a return value.
B. A compilation error will be encountered at //2, since the class does not have a
default constructor.
C. A compilation error will be encountered at //3.
D. The program will compile correctly.
E. It will not compile because parameter type of the constructor is different than the
type of value passed to it.

59. Which of the following are reserved words in Java?


Select 2 option(s):
A. goto
B. package
C. export
D. array
E. hash
60. What will happen when the following code is compiled?

public class FooBar


{
private int FooBar; //1
public FooBar(int FooBar){ this.FooBar = FooBar; } //2
public void FooBar(){ } //3
}
Select 1 option(s):
A. Compilation error at //1. Eventho same name but semua lain jenis, one is variable, one is
B. Compilation error at //2. constructor, one is method
C. Compilation error at //3.
D. Compiles without any error.

You might also like