Java OOP - 2

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

c

Consider the following Java program : class IfStatement{ public static void main(String args[]) { int a=2, b=3; if (a==3) if (b==3) System.out.println("==============="); else System.out.println("#################"); System.out.println("&&&&&&&&&&&"); } } Which of the following will the output be? (a) =============== (b) ################# &&&&&&&&& (c) &&&&&&&&&&& (d) =============== ################# &&&&&&&&&& (e) ################.

c

In java, objects are passed as (a) Copy of that object (b) Method called call by value (c) Memory address (d) Constructor (e) Default constructor.

a

The correct order of the declarations in a Java program is, (a) Package declaration, import statement, class declaration (b) Import statement, package declaration, class declaration (c) Import statement, class declaration, package declaration (d) Class declaration, import statement, package declaration (e) Class declaration, package declaration, import statement.

c

What is garbage collection in the context of Java? (a) The operating system periodically deletes all the java files available on the system. (b) Any package imported in a program and not used is automatically deleted. (c) When all references to an object are gone, the memory used by the object is automatically reclaimed. (d) The JVM checks the output of any Java program and deletes anything that doesn't make sense. (e) Janitors working for Sun Micro Systems are required to throw away any Microsoft documentation found in the employees' offices.

c

A protected member can be accessed in, (a) a subclass of the same package (b) a non-subclass of the same package (c) a non-subclass of different package (d) a subclass of different package (e) the same class. Which is the false option?

d

All exception types are subclasses of the built-in class (a) Exception (b) RuntimeException (c) Error (d) Throwable (e) None of the above.

d

An applet cannot be viewed using (a) Netscape navigator (b) Microsoft Internet Explorer (c) Sun' Hot Java Browser (d) Applet viewer tool which comes, with the Java Development Kit. (e) Jbuilder. Use the following Java program for answering question 11 and 12 class test{ void meth(int i, int j) { i *= 2; i /= 2; } } class argumentPassing { public static void main(String args[]) { test ob = new test(); int a = 15, b = 20; System.out.println("a and b before call :"+ a +" " + b); ob.meth(a,b); System.out.println("a and b after call : "+ a + " " +b); }

d

An overloaded method consists of, (a) The same method name with different types of parameters (b) The same method name with different number of parameters (c) The same method name and same number and type of parameters with different return type (d) Both (a) and (b) above (e) (a), (b) and (c) above.

c

Identify, from among the following, the incorrect variable name(s). (a) _theButton (b) $reallyBigNumber (c) 2ndName (d) CurrentWeatherStateofplanet (e) my2ndFont. Use the following declaration and initialization to evaluate the Java expressions given in questions 5 - 8; int a = 2, b = 3, c = 4, d = 5; float k = 4.3f;

d

Mark the incorrect statement from the following: (a) Java is a fully object oriented language with strong support for proper software engineering techniques (b) In java it is not easy to write C-like so called procedural programs (c) In java language objects have to be manipulated (d) In java language error processing is built into the language (e) Java is not a language for internet programming.

b

The java run time system automatically calls this method while garbage collection. (a) finalizer() (b) finalize() (c) finally() (d) finalized() (e) none of the above.

e

Use the following declaration and initialization to evaluate the Java expressions int a = 2, b = 3, c = 4, d = 5; float k = 4.3f; System.out.println (-2U * ( g - k ) +c); (a) 6 (b) 3 (c) 2 (d) 1 (e) Syntax error.

b

Use the following declaration and initialization to evaluate the Java expressions int a = 2, b = 3, c = 4, d = 5; float k = 4.3f; System.out.println (c=c++); (a) 2 (b) 4 (c) 5 (d) 8 (e) Syntax error.

b

Use the following declaration and initialization to evaluate the Java expressions int a = 2, b = 3, c = 4, d = 5; float k = 4.3f; System.out.println( - -b ** a + c **d - -); (a) 21 (b) 24 (c) 28 (d) 26 (e) 22.

b

Use the following declaration and initialization to evaluate the Java expressions int a = 2, b = 3, c = 4, d = 5; float k = 4.3f; System.out.println(a++); (a) 3 (b) 2 (c) 4 (d) 10 (e) Synatax error.

a

What is byte code in the context of Java? (a) The type of code generated by a Java compiler. (b) The type of code generated by a Java Virtual Machine. (c) It is another name for a Java source file. (d) It is the code written within the instance methods of a class. (e) It is another name for comments written within a program.

b

What is the output of the following code: class eq { public static void main(String args[]) { String s1 = "Hello"; String s2 = new String(s1); System.out.println(s1==s2); } } (a) true (b) false (c) 0 (d) 1 (e) Hello.

b

When an overridden method is called from within a subclass, it will always refer to the version of that method defined by the (a) Super class (b) Subclass (c) Compiler will choose randomly (d) Interpreter will choose randomly (e) None of the abvove.

c

Which of the following is not a component of Java Integrated Development Environment (IDE)? (a) Net Beans (b) Borland's Jbuilder (c) Symantec's Visual Café (d) Microsoft Visual Fox Pro (e) Microsoft Visual J++.

b

You read the following statement in a Java program that compiles and executes. submarine.dive(depth); What can you say for sure? (a) depth must be an int (b) dive must be a method. (c) dive must be the name of an instance field. (d) submarine must be the name of a class (e) submarine must be a method.


Kaugnay na mga set ng pag-aaral

Practice Questions Non-covalent interactions/water

View Set

MSII Quiz 12 — Psychiatric Disorders

View Set

Chapter 8 Information Gathering and Processing in Retailing

View Set

Patient Care - Infection Control & management Review Test

View Set

Chapter 12 Practical Applications

View Set