Sie sind auf Seite 1von 14

Multiple choice questions for Advanced computer diploma course Section -1 : C++ 1.

Inline functions are invoked at the time of a) Run time b) Compile time c) Depends on how it is invoked d) Both b and c above 2. Which of the following operators below allow to defining the member functions of a class outside the class? a) :: b) ? c) :? d) % 3. Every class has at least one constructor function, even when none is declared. a) True b) False 4. How do we define a destructor? a) X~() {} b) X() {}~ c) X() ~{} d) ~X() {} 5. Can constructors be overloaded? a) No b) Yes 6. Which of the following below can perform conversions between pointers to related classes? a) cast_static b) dynamic_cast c) static_cast d) cast_dynamic 7. An abstract class can be instantiated. a) True b) False 8. The default access level assigned to members of a class is ___________ a) Private b) Public c) Protected d) Needs to be assigned 9. Which classes allow primitive types to be accessed as objects? a) Storage b) Virtual c) Friend d) Wrapper

Page 1 of 14

10 . Consider the declaration: char arr[15]; What does arr point to? a) Starting address of the array b) Size of the array c) Ending address of the array d) Number of elements in the array 11. What is the difference between overloaded functions and overridden functions? a) Overloading is a dynamic or run-time binding and Overriding is static or compile-time binding b) Redefining a function in a friend class is called function overriding while Redefining a function in a derived class is called a overloaded function. c) Overloading is a static or compile-time binding and Overriding is dynamic or run-time binding d) Redefining a function in a friend class is called function overloading while Redefining a function in a derived class is called as overridden function. 12. What is shallow copy? a) A shallow copy creates a copy of the dynamically allocated objects too. b) A shallow copy just copies the values of the data as they are. c) A shallow copy creates a copy of the statically allocated objects too d) Both b and c above 13. Which of the following library function below by default aborts the program? a) Terminate() b) end() c) Abort() d) exit() 14. What defines a general set of operations that will be applied to various types of data? a) Template class b) Function template c) Class template d) Both a and c above 15. What happens when a pointer is deleted twice? a) It can abort the program b) It can cause a failure c) It can cause an error d) It can cause a trap 16. What is deep copy? a) A deep copy creates a copy of the dynamically allocated objects too. b) A deep copy just copies the values of the data as they are. c) A deep copy creates a copy of the statically allocated objects too d) Both b and c above 17. There is nothing like a virtual constructor of a class. a) False b) True 18. What is the Difference between struct and class in terms of Access Modifier? a) By default all the struct members are private while by default class members are public. b) By default all the struct members are protected while by default class members are private. c) By default all the struct members are public while by default class members are private.

Page 2 of 14

d) By default all the struct members are public while by default class members are protected. 19 . When a subclass inherits from a class which itself has inherited from another class, it is known as: a) Multilevel inheritance b) Single inheritance c) Multiple inheritance d) Hierarchical Inheritance 20. C++ provides facility to specify that the compiler should match function calls with the correct definition at the run time. This process is called as a) Static binding b) Dynamic Binding c) All of the above d) None of the above Section 2 : Access 1. In MS Access, Text Data type may contain maximum character of A. 255 Character B. 256 Character C. 1064 Character D. No Limit 2. Which of the following is not a valid Data Type in MS Access? A. Memo B. Picture C. Currency D. AutoNumber 3. In MS Access Hyperlink Data Type can store A. Web Address B. email Address C. Path of a File D. All of Above 4. Which of the following data type is used to store logical value in MS Access? A. True/False B. On/Off C. Yes/No D. All of Above 5. The appropriate Data Type to store Time in MS Access? A. Date/Time B. Time Only C. Time D. Time cannot be stored 6. In MS Access Lookup Wizard is used to A. to select from previous values B. to select values from Excel Sheet

Page 3 of 14

C. to select value from another table D. Not a valid Data Type 7. Which of the following Data Type is used to store picture in MS Access A. Picture B. OLE Object C. Memo D. Picture cannot be stored 8. in MS Access, which data type is appropriate to store large text and numbers? A. Text B. Memo C. OLE D. Large Text 9. in MS Access, OLE Object Data type can store A. Microsoft Word documents B. Microsoft Excel spreadsheets C. Sounds D. All of the Above 10 in MS Access, AutoNumber Data Type A. Can be Sequential B. Can be Random C. Can be Edited D. Only A & B Section 3: VB. Net 1. Which statement is true? a) A base class inherits some of the properties of a derived class. b) A base class inherits all of the properties of a derived class. c) A derived class inherits some of the properties of a base class. d) A derived class inherits all of the properties of a base class. e) None of the above. When a base class is changed: a) There is no effect on the derived class. b) The derived class changes when the key word Overridden is used. c) Only the methods of the derived class change. d) Only the properties of the derived class change. e) The derived class automatically changes. Polymorphism can apply to: a) math operators. b) method names. c) object names. d) Both a and b. e) All of the above. With polymorphism: a.) one method can have multiple names.

2.

3.

4.

Page 4 of 14

b.) c.) d.) e.) 5.

one object can have multiple names. many methods can share the same name. many objects can share the same name. None of the above statements are true.

Which element of a class is optional? a.) Constructs b.) Fields c.) Methods d.) Properties e.) All of the above. What is the suggested order for the definition of class elements from first to last? a.) Constructs, fields, methods, properties b.) Properties, constructs, fields, methods c.) Fields, properties, constructs, methods d.) Constructs, properties, fields, methods e.) Methods, constructs, properties, fields The standard for designing a field is that it be defined as a: a.) private method. b.) public method. c.) private variable. d.) public variable. e.) None of the above. What is the syntax for making a property read-only? a.) Property Read propertyname As datatype b.) Read Property propertyname As datatype c.) ReadOnly Property propertyname As datatype d.) Read-Only Property propertyname As datatype e.) RO Property propertyname As datatype The Get procedure of a property acts like: a.) an event. b.) a function. c.) a variable. d.) Both a and b. e.) All of the above. A method in a class is: a.) a sub procedure. b.) a function. c.) an event. d.) Both a and b. e.) All of the above. How many constructors can a class have? a.) 0 b.) 1 c.) 2 d.) 3

6.

7.

8.

9.

10.

11.

Page 5 of 14

e.) none. 12. A constructor is a special type of: a.) class. b.) field. c.) method. d.) property. e.) variable. Which is true for constructors in a class? a.) All constructors must have the same number of parameters. b.) All constructors must be the same parameter data type. c.) Some constructors can have the same list of parameters. d.) Only two constructors in a class can have the same list of parameters. e.) No two constructors in a class can have the same list of parameters. Which statement will call a constructor of a base class? a.) Base.New( ) b.) BaseConstructor.New ( ) c.) CallBase.New( ) d.) Constructor.New ( ) e.) MyBase.New( ) Which DataAdapter Query Type can be used with the Access database? a.) Use SQL statements. b.) Create new stored procedure. c.) Use existing stored procedure. d.) Both a and b. e.) All of the above. Which is not an ADO.NET DataAdapter Object? a.) OleDbDataAdapter b.) SQLDataAdapter c.) QueryDataAdapter d.) Both a and b. e.) All of the above. Which is the appropriate prefix for a DataAdapter object? a.) da b.) daa c.) dad d.) dt e.) dta Which type of object has the Generate Dataset method? a.) Adapter object b.) Connection object c.) Database object d.) Dataset object e.) None of the above. Which is the appropriate prefix for a Dataset object?

13.

14.

15.

16.

17.

18.

19.

Page 6 of 14

a.) b.) c.) d.) e.) 20.

da das dat ds dst

Which object does the data-aware control bind to? a.) Dataset b.) DataAdapter c.) Connection d.) Both a and b. e.) All of the above. Sec 4: J2ME

1. Which of the following statements is true about Java ME? A. Java ME is a single specification. B. Java ME is a family of related specifications. C. Java ME is a platform for creating applications for the well-established desktop market. D. Java ME is a platform for creating server-side enterprise applications. 2. A Java ME-enabled device: A. Can support only a single profile B. Can support multiple profiles 3. Which of the following network connections is supported by MIDP? A. UDP datagrams B. WAP C. HTTP D. All of the above 4. In MIDP, the maximum length of a record store name is: A. 8 characters B. 32 characters C. 128 characters D. No limit on the length of a record store name 5. The CLDC does not address user interface issues. They are left to be handled by the: A. Foundation profile B. Personal profile C. Mobile Information Device Profile (MIDP) D. None of the above 6. The CDC and Foundation make corrections to the J2SE libraries by removing all noncritical, deprecated APIs. | A. True B. False

7. All MIDP GUI classes are contained in what package? A. javax.microedition.gui B. javax.microedition.lcd C. javax.microedition.lcdui

Page 7 of 14

D. javax.microedition.display 8. What compilation option should be used when compiling Java ME applications? A. -classpath B. -bootclasspath C. -preverify D. Any of the above 9. A Java virtual machine1 (JVM) supporting CLDC has no support for: A. Floating point numbers B. Reflection C. JNI D. All of the above 10. What is a configuration? A. A configuration defines a set of class libraries available for a particular domain of devices. B. A configuration defines a vertical (or specialized) set of classes. C. A configuration defines a minimum set of class libraries for a wide range of devices. D. All of the above. Section 5 : Java SE 1. Read this piece of code carefullyif("String".toString() == "String") System.out.println("Equal"); else System.out.println("Not Equal"); a. the code will compile an print Equal. b. the code will compile an print Not Equal. c. the code will cause a compiler error. 2. Read this piece of code carefullyif("String".trim() == "String") System.out.println("Equal"); else System.out.println("Not Equal"); a. the code will compile an print Equal. b. the code will compile an print Not Equal. c. the code will cause a compiler error 3. Read the code below. Will be the result of attempting to compile and run the code below. public class AQuestion { public void method(Object o){ System.out.println("Object Verion"); } public void method(String s){ System.out.println("String Version"); } public static void main(String args[]){

Page 8 of 14

AQuestion question = new AQuestion(); question.method(null); } } a. b. c. d. 4. The code does not compile. The code compiles cleanly and shows Object Version. The code compiles cleanly and shows String Version The code throws an Exception at Runtime.

Read the code below. Will be the result of attempting to compile and run the code below. public class AQuestion{ public void method(StringBuffer sb){ System.out.println("StringBuffer Verion"); } public void method(String s){ System.out.println("String Version"); } public static void main(String args[]){ AQuestion question = new AQuestion(); question.method(null); } } a. The code does not compile. b. The code compiles cleanly and shows StringBuffer Version. c. The code compiles cleanly and shows String Version d. The code throws an Exception at Runtime.

5.

Read the following code below.

public interface AQuestion{ public abstract void someMethod() throws Exception; } A Class implementing this interface shoulda. Necessarily be an abstract class. b. Should have the method public abstract void someMethod(); c. Should have the method public void someMethod() which has to throw an exception which is a subclass of java.lang.Exception. d. Should have the method public void someMethod() which need not throw an Exception. 6. An Interface can never be private or protected. a) True b) False A String Class a. is final b. is public

7.

Page 9 of 14

c. is serializable d. has a constructor which takes a StingBuffer Object as an Argument 8. public interface AQuestion{ void someMethod(); } The class which implements AQuestion a) b) c) d) 9. Should have someMethod which must necessarily be public. Should have someMethod which could be friendly or public Should have someMethod which should not throw any checked exceptions. Should have someMethod which cannot be sychronized as sychronized is not in the signature of the interface definition

public class AQuestion{ private int i = j; private int j = 10; public static void main(String args[]){ System.out.println((new AQuestion()).i); } } a. Compiler error complaining about access restriction of private variables of AQuestion. b. Compiler error complaining about forward referencing. c. No error - The output is 0; d. No error - The output is 10; Consider the following program: import myLibrary.*; public class ShowSomeClass { // code for the class... } What is the name of the java file containing this program? a. myLibrary.java b. ShowSomeClass.java c. ShowSomeClass d. ShowSomeClass.class e. Any file name with the java suffix will do Which of the following is TRUE? a) In java, an instance field declared public generates a compilation error. b) int is the name of a class available in the package java.lang c) Instance variable names may only contain letters and digits. d) A class has always a constructor . e) The more comments in a program, the faster the program runs. Consider the following code snippet:String river = new String(Columbia); System.out.println(river.length()); What is printed? a) 6

10.

11.

12.

Page 10 of 14

b) c) d) e) 13. A constructor ,

7 8 Columbia river

14.

15

16.

17.

a) must have the same name as the class it is declared within. b) is used to create objects. c) may be declared private d) A and B e) A, B and C Which of the following may be part of a class definition? a) instance variables b) instance methods c) constructors d) all of the above e) none of the above What is different between a Java applet and a Java application? a) An application can in general be trusted whereas an applet can't. b) An applet must be executed in a browser environment. c) An applet is not able to access the files of the computer it runs on d) (a), (b) and (c). e) None of the above What is garbage collection in the context of Java? a) The operating system periodically deletes all of 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 MicroSystems are required to throw away any Microsoft documentation found in the employees' offices. You read the following statement in a Java program that compiles and executes. submarine.dive(depth); What can you say for sure? a) b) c) d) e) depth must be an int dive must be a method. dive must be the name of an instance field. submarine must be the name of a class submarine must be a method

18.

What will be the result of attempting to compile and run the following program? public class MyClass { public static void main(String[] args) { String s = "hello"; StringBuilder sb = new StringBuilder(s); sb.reverse(); if (s == sb) { System.out.println("a"); } if (s.equals(sb)) { System.out.println("b");

Page 11 of 14

19.

} if (sb.equals(s)) { System.out.println("c"); } } } a) The code will fail to compile because the constructor of the String class is not called properly. b) The code will fail to compile because the expression (s == sb) is illegal. c) The code will fail to compile because the expression (s.equals(sb)) is illegal. d) The program will print c, when run. In object-oriented design a. operations and methods are identical b. methods do not change values of attributes c. methods and constructor are same d. methods specify algorithms, whereas operations only state what is to be done What will be the result of compiling and running the following program? public class NewClass2 { public static void main(String[] args) { NewClass2 obj = new NewClass2(n); } static int i = 5; static int n; int j = 7; int k; public NewClass2(int m) { System.out.println(i + ", " + j + ", " + k + ", " + n + ", " + m); } { j = 70; n = 20; } // Instance Initializer Block static { i = 50; } // Static Initializer Block } a) The code will fail to compile because the instance initializer block tries to assign a value to a static field. b) The code will fail to compile because the field k will be uninitialized when it is used. c) The code will compile and print 50, 70, 0, 20, 0 when run. d) The code will compile and print 50, 70, 0, 20, 20 when run. Each statement below is either TRUE or FALSE. Choose the most appropriate one . a) Objects selected to model a system must have all attributes which are invariant during operations of a system. b) Use cases are not beneficial for all interface requirements.

20.

21.

Page 12 of 14

c) Java considers the variables number and NuMbEr to be identical. d) e) An instance member belongs to an instance, not to the class as a whole. If the references x and y denote two different objects, the expression x.equals(y) is always false.

f) Subclasses of the String class can be mutable. g) A local variable in a block cannot be redeclared in another block even if the blocks are disjoint. h) i) j) If an exception is thrown during the execution of the finalize() method of an eligible object, the exception is ignored and the object is destroyed. A constructor can be declared private. The import declarations must be the first statement after any package declaration in a source file.

Section 5 : Java SE &EE


1. The method getWriter returns an object of type PrintWriter. This class has println methods to generate output. Which of these classes define the getWriter method? Select the one correct answer. a) HttpServletRequest b) HttpServletResponse c) ServletConfig d) ServletContext Name the method defined in the HttpServletResponse class that may be used to set the content type. a) setContentType () b) HttpServletContentType() c) setHttpServletContentType () d) setContentType () e) HttpServletResponseContentType() Which of the following statements is correct. Select the one correct answer. a. The response from the server to a HEAD request consists of status line, content type and the document. b. The response from the server to a GET request does not contain a document. c. The setStatus method defined in the HttpServletRequest class takes an int as an argument and sets the status of Http response d. The HttpServletResponse defines constants like SC_NOT_FOUND that may be used as a parameter to setStatus method. The sendError method defined in the HttpServlet class is equivalent to invoking the setStatus method with the following parameter. Select the one correct answer. a) SC_OK b) SC_MOVED_TEMPORARILY c) SC_NOT_FOUND d) SC_INTERNAL_SERVER_ERROR e) ESC_BAD_REQUEST

2.

3.

4.

Page 13 of 14

5.

The sendRedirect method defined in the HttpServlet class is equivalent to invoking the setStatus method with the following parameter and a Location header in the URL. Select the one correct answer. a) SC_OK b) SC_MOVED_TEMPORARILY c) SC_NOT_FOUND d) SC_INTERNAL_SERVER_ERROR e) ESC_BAD_REQUEST Which of the following statements are correct about the status of the Http response. a) A status of 200 to 299 signifies that the request was succesful. b) A status of 300 to 399 are informational messages. c) A status of 400 to 499 indicates an error in the server. d) A status of 500 to 599 indicates an error in the client. To send binary outptut in a response, the following method of HttpServletResponse may be used to get the appropriate Writer/Stream object. Select the one correct answer. A. getStream B. getOutputStream C. getBinaryStream D. getWriter To send text outptut in a response, the following method of HttpServletResponse may be used to get the appropriate Writer/Stream object. Select the one correct answer. A. getStream B. getOutputStream C. getBinaryStream D. getWriter URL rewriting may be used when a browser is disabled. In URL encoding the session id is included as part of the URL. a) True b) False Name the class that includes the getSession method that is used to get the HttpSession object. A. HttpServletRequest B. HttpServletResponse C. SessionContext D. SessionConfig

6.

7.

8.

9.

10.

Page 14 of 14