Category Archives: Upwork General Programming

Upwork General Programming

Visual Basic 6 Test 2016

Published by:

1. An ADO dynamic property is:

Answers:

  1. A property that changes value at runtime
  2. A value defined by the user
  3. A value defined by the operating system
  4. A property that dynamically resizes as needed to accommodate database parameters
  5. A property implemented by the OLE DB service provider

2. In order to provide a transparent background to the Form, you must change the _________ property to _______.

Answers:

  1. BackStyle, Opaque
  2. BackColor, White
  3. BackStyle, Transparent
  4. BackColor, Parent Window’s Color
  5. ZOrder, 0
  6. BackColor, Transparent

3. Which of the following cannot be included in the Open method of the recordset?

Answers:

  1. Cursor Type
  2. User Name
  3. Active Connection
  4. CursorLocation
  5. LockType
  6. Source

4. What does the controls collection contain?

Answers:

  1. A list of all controls on a form
  2. A list of all the controls used by your program
  3. A list of all text boxes on a form
  4. A list of all visible controls
  5. The names of all control arrays on the form

5. You are creating a client application that calls ActiveX DLLs. Which of the following properties of the Err object provides the name of a component that sends an error back to the client application?

Answers:

  1. Number
  2. Description
  3. CompName
  4. Component
  5. Source
  6. Text
  7. Desc
  8. None of the above

6. Global Procedures and Global Variables are declared in:

Answers:

  1. Form Modules
  2. Standard (Code) Modules
  3. Class Modules
  4. Resource files
  5. ActiveX Controls
  6. Data Environment

7. Given the following code segment, how many instances of the form are created and displayed ?

dim frmvar1 as frmperson,frmvar2 as frmperson
set frmvar1 = new frmperson
set frmvar2 = frmvar1
load frmvar1
frmvar2.show

Answers:

  1. None
  2. 1
  3. 2
  4. 3
  5. 4
  6. 5
  7. 6
  8. 7

8. Only Controls with a ________ property such as Picturebox, Toolbox, Statusbar etc. can be placed on an MDI form:

Answers:

  1. Showtips
  2. Negotiate
  3. Align
  4. BorderStyle = 0
  5. Visible
  6. Locked
  7. Enabled
  8. Tag

9. Whenever the current record is about to change, Visual Basic generates the ______ event:

Answers:

  1. Validate
  2. UpdateRecords
  3. UpdateControls
  4. BeginTrans
  5. BeginMove
  6. Update

10. Which of the following will provide the best aggregate performance for a query that is not executed repeatedly?

Answers:

  1. Direct execution
  2. Stored procedures
  3. Prepared statements
  4. Data Environment
  5. ADO Data Control

11. The _______ property enables Visual Basic to draw complete images in memory before displaying them on the Screen.

Answers:

  1. AutoRedraw = True
  2. AutoRedraw = False
  3. Refresh
  4. PaintPicture

12. Which event of an ActiveX control data provider runs every time a bound control extracts data through the provider?

Answers:

  1. GetDataMember
  2. GetDataField
  3. GetDataProperty
  4. GetDataRow
  5. GetData
  6. GetFields
  7. GetRows
  8. RetrieveData

13. Which event should you use to store property values into the PropertyBag?

Answers:

  1. Terminate
  2. ReadProperties
  3. StoreProperties
  4. WriteProperties
  5. SaveProperties
  6. CommitProperties

14. One can convert a Visual Basic Application into ActiveX Document using:

Answers:

  1. Visual Database Manager
  2. Application Wizard
  3. ActiveX Document Migration Wizard
  4. Package and Deployment Wizard

15. Which event should be used to resize an ActiveX control as the user modifies the size of the control implementation on a form?

Answers:

  1. Resize
  2. Paint
  3. Repaint
  4. Initialize
  5. Change
  6. ReDimension
  7. Dimension
  8. Any of the above

16. The ______ function can be used to run any .com, .exe, .bat or .pif file from a Visual Basic program.

Answers:

  1. Shell
  2. Substr
  3. SetAttr
  4. CStr
  5. Exec
  6. Perform
  7. Do
  8. None of the above

17. Consider the following program code:

(i) Dim FileName as String
Open FileName For Input As #FreeFile

(ii) Dim FileName as String
FileNum = FreeFile
Open FileName For Input As #FileNum

Answers:

  1. Both (i) and (ii) are correct
  2. Only (i) is correct
  3. Only (ii) is correct
  4. (i) contains a logical error
  5. (ii) contains an error
  6. Both (i) and (ii) contain errors

18. Which function or method will you use to get a count of the maximum index limit of an array?

Answers:

  1. UBound function
  2. LBound function
  3. Substr function
  4. Bound Control method
  5. Limit method
  6. UpperLimit method
  7. Upper method
  8. MaxArray function

19. Which property of the ProgressBar determines how much of the bar is filled?

Answers:

  1. Min
  2. Max
  3. Value
  4. CurrentVal
  5. FillValue
  6. Fill
  7. BarComplete

20. In order to change the mouse pointer shape from glass to watch-glass, the property to be used is:

Answers:

  1. MousePointer
  2. Picture
  3. Menu
  4. PointerStyle
  5. Pointer
  6. Cursor
  7. CursorStyle
  8. CursorShape

21. The caption and the name properties of the command button:

Answers:

  1. Are one and the same
  2. Can be different at times
  3. Are actually not properties

22. In order to access a file in Non-textual format, you have to open file in:

Answers:

  1. Ascii Format
  2. Binary Format
  3. Input Mode
  4. Output mode
  5. Append mode
  6. Read Mode

23. What is the extension of the Visual Basic project file that stores the design of a user control.

Answers:

  1. .ctx
  2. .ctl
  3. .ctr
  4. .ocx
  5. .vbp
  6. .dll
  7. .ucl
  8. .utl

24. After a Dynaset type recordset has been created and opened, further searching is possible using the:

Answers:

  1. LookUp method
  2. Seek method
  3. Locate method
  4. FindNext method
  5. Search method

25. Which method of the Recordset object should you use to navigate multiple recordsets returned by a stored procedure?

Answers:

  1. NewRecordset
  2. NavigateRecordset
  3. OpenNextRecordset
  4. NextRecordset
  5. SkipRecordset
  6. PreviousRecordset
  7. JumpRecordset
  8. GoTORecordset

26. Which event procedure is called only if AutoRedraw property is set to false:

Answers:

  1. Form_GotFocus
  2. Form_Paint
  3. Form_Activate

27. Which events enable you to determine which key was pressed by the user?

Answers:

  1. Click and KeyPress
  2. Click, KeyUp and KeyDown
  3. KeyUp and KeyDown
  4. KeyPress, KeyUp and KeyDown
  5. Click, KeyPress, KeyUp and KeyDown

28. The Kill command in Visual Basic is used for:

Answers:

  1. Stopping the current process
  2. Deleting files
  3. Terminating the application
  4. Stopping the current thread
  5. Debugging the application
  6. Error handling
  7. None of the above

29. Which method would you use to get a free or unused File identifier while opening any file:

Answers:

  1. FreeFile
  2. GetFileNum
  3. GetFile
  4. GetBytes
  5. NextFile
  6. File
  7. GetNextFile
  8. None of the above

30. What data type is the HelpContextID?

Answers:

  1. String
  2. Integer
  3. Single
  4. Double
  5. Long
  6. Char
  7. Float

31. Which event is fired when a text box loses focus?

Answers:

  1. LostFocus
  2. FocusLost
  3. RemoveFocus
  4. FocusAway
  5. NoFocus
  6. Leavefocus

32. Message Boxes can hold a maximum of _______ characters.

Answers:

  1. 256
  2. 512
  3. 1024
  4. 2046
  5. 4092
  6. 5000
  7. 10000
  8. No limit

33. Which of the following is the only valid Resume statement in an error handler?

Answers:

  1. Resume prior
  2. Resume previous
  3. Resume later
  4. Resume next
  5. Resume before
  6. Resume to
  7. Resume statement
  8. Resume application

34. To store pictures in an array, Visual Basic provides the _____ control.

Answers:

  1. PictureClip<
  2. ImageList
  3. PictureBox
  4. Image Box
  5. Timer Control
  6. ListView
  7. Common Dialog
  8. DataGrid

35. Which is the only event of the timer control?

Answers:

  1. Timer
  2. TimeElapsed
  3. TimeOver
  4. Reset
  5. TimeOut
  6. Restart
  7. Freeze
  8. Stop

36. Consider the following subprogram:

Sub ChangeText(ByVal X as String,Y as String)
Y = X
End Sub
If you are calling it using the following code:

Call ChangeText(Form1.Caption,Y$)

Answers:

  1. The Caption of Form1 will change to the value contained in Y$
  2. The Caption of Form1 will not change
  3. The Caption changes at random intervals after the function call
  4. The code is incorrect

37. If one needs to use an ampersand(&) in a Label but does not want it to be an Access Key, the _______ property of the label must be set to False.

Answers:

  1. Caption
  2. ClipControls
  3. UseMnemonic
  4. LinkMode
  5. Locked
  6. Label
  7. ZOrder
  8. Visible

38. What is the sequence of events when a form is unloaded?

Answers:

  1. QueryUnload, Unload and Terminate
  2. QueryUnload, Terminate and Unload
  3. QueryUnload and Unload
  4. Unload only
  5. Terminate, QueryUnload and Unload
  6. Terminate, Unload and QueryUnload
  7. Unload, QueryUnload and Terminate
  8. Unload, Terminate and QueryUnload

39. What is the default value for the scalemode property of the form?

Answers:

  1. Twip
  2. Point
  3. Pixel
  4. Character
  5. Centimeter
  6. Inches
  7. Millimeters

40. Which property of the Err object returns the numeric value associated with the most recent runtime error?

Answers:

  1. Description
  2. No
  3. Number
  4. Source
  5. Errorcode
  6. Num
  7. Code

41. The event Lost_Focus of one object results in _____ of the other object:

Answers:

  1. Got_Focus
  2. Lost_Focus
  3. Mouse_click
  4. Refresh
  5. Validate
  6. Load
  7. Activate
  8. Initialize

42. Which of the following ADO recordset types provides the greatest degree of concurrency?

Answers:

  1. Static
  2. Forward-only
  3. Dynamic
  4. Keyset
  5. Read only
  6. Keyset and Dynamic

43. The ______ property is used to show Tool Tips or Help Balloons when the mouse rests on the object:

Answers:

  1. ToolTipText
  2. Tag
  3. Dragmode
  4. ShowTips
  5. Help
  6. Tip
  7. ShowHelp
  8. Tab

44. Which of the following can be shown to the user using the Common Dialog control in VB?

Answers:

  1. Common messages passed to Windows
  2. Open dialog box
  3. Windows explorer
  4. Input box
  5. Message box
  6. Error messages
  7. Help
  8. None of the above

45. Which property of the form changes the form’s title?

Answers:

  1. Name
  2. Heading
  3. Caption
  4. Text
  5. Title

46. In order to enable the DBGridControl or the MSFlexGrid Control to display the contents of a table or query, you need to set only the ______ property:

Answers:

  1. DataSource
  2. Connection
  3. RecordSource
  4. TableType
  5. RecordType
  6. DataType

47. In Visual Basic, which method can you use to send key strokes to other Window applications?

Answers:

  1. AppActivate
  2. SendKeys
  3. Copying the contents from the ClipBoard & pasting
  4. Manually typing in the other application’s Window

48. The _______ property changes the tab order at runtime:

Answers:

  1. Tab stop
  2. Tab key
  3. Tab order
  4. Tab index

49. Which of the following tools can be used to change the value of a variable or property during break mode of an application?

Answers:

  1. Watch window
  2. Immediate window
  3. Callstack
  4. Locals window
  5. Debug object

50. You want the code of the close command button to execute upon pressing the ESC key, even though the focus may be on another control in the form. Which property of the command button would you set to true?

Answers:

  1. Cancel
  2. Escape
  3. Exit
  4. Focus
  5. Default
  6. Losefocus
  7. ExecEvent
  8. FireEvent

51. Which collection of an ActiveX control enumerates all of the properties that can be bound to a data source?

Answers:

  1. DataFields
  2. DataMembers
  3. DataBindings
  4. DataProperties
  5. DataBase
  6. DataColumns

52. Which of the following situations would not cause the Initialize event of an ActiveX control to occur?

Answers:

  1. When a control is placed on a form at design time
  2. When a form designer containing a control is closed
  3. When a form is run
  4. When a compiled application containing a control executes
  5. When an application terminates and re-enters design-time for the host application

53. You can create menus by the ________ and _________.

Answers:

  1. Menu Editor, Application Wizard
  2. Menu Editor, Win32 API
  3. Win32 API, Application Wizard
  4. Class Builder, New Application Wizard

54. What is the sequence in which the following events are triggered when a form is loaded?

Answers:

  1. Initialize, Load, Resize and Paint
  2. Initialize, Load, Paint and Resize
  3. Load, Initialize, Resize and Paint
  4. Load, Initialize, Paint and Resize
  5. Initialize, Resize, Paint and Load
  6. Load, Paint,Initialize and Resize
  7. Initialize, Paint, Load and Resize
  8. Paint, Resize, Initialize and Load

55. Visual Basic displays information depending upon the current value of two properties of the form, called:

Answers:

  1. CurrentX and CurrentY
  2. ScaleLeft and ScaleTop
  3. ScaleHeight and ScaleTop
  4. x and y
  5. TopX and TopY
  6. LeftX and LeftY

56. Which of the following statements is capable of abandoning a series of modifications made to a recordset locked with a BatchOptimistic lock?

Answers:

  1. CancelUpdate
  2. CancelBatch
  3. CancelBatchUpdate
  4. AbandonBatch
  5. AbandonBatchUpdate
  6. Rollbackupdate
  7. Rollbackbatch
  8. None of the above

57. Which of the following is the valid stepping option?

Answers:

  1. Step Around
  2. Step Beyond
  3. Step Over
  4. Step Behind
  5. Step forward
  6. Step Into
  7. Step Out

58. Procedures declared in a _____ are local whereas procedures declared in a ______ are available to the whole application.

Answers:

  1. Form window, standard or code module
  2. Project window, view code window
  3. Class module, code module

59. Which property of the ListView control determines which field a sort is based on?

Answers:

  1. Sorted
  2. SortKey
  3. SortOrder
  4. SortField
  5. Sort
  6. Key
  7. ListKey
  8. None of the above

60. The method used to search for records from within a table type recordset object is:

Answers:

  1. LookUp
  2. Seek
  3. Locate
  4. FindNext
  5. Search

61. Which of the following methods is used to inform an ActiveX control’s container that one of its properties has been modified?

Answers:

  1. PropertyChanged
  2. CanPropertyChange
  3. ModifyProperty
  4. PropertyModify
  5. PropertyChange
  6. PropertyModified
  7. ChangeProperty

62. Which event is triggered when the user moves to another open form?

Answers:

  1. Unload
  2. QueryUnload
  3. Deactivate
  4. Terminate
  5. Load
  6. Initialize
  7. Repaint
  8. Resize

63. Which of the following is an event of the Shape control?

Answers:

  1. GotFocus
  2. LostFocus
  3. Validate
  4. KeyPress
  5. A shape control does not have events

64. What is the purpose of the Image List Control?

Answers:

  1. To display images to the user
  2. To help in creating a ToolBar
  3. To allow the editing of icons
  4. To provide a repository for images used by other controls
  5. To provide images to the listbox control
  6. To provide images for the splash screen
  7. To provide icons for error messages

65. Which line of code listed here can be used to create a string of fixed length:

Answers:

  1. Dim strFirstName as String
  2. strFirstName * 255
  3. strFirstName = 255
  4. Dim strFirstName as String(255)
  5. None of the above

66. Which of the following statements is incorrect regarding toolbars?

Answers:

  1. There can be only one toolbar on a form
  2. Toolbars can be positioned anywhere on the form
  3. Toolbars can be customized by the user
  4. Toolbar buttons can display images
  5. Toolbar buttons can display text
  6. Toolbars can have both images and buttons

67. Which of the following statements should you write to cause the component to fire an event?

Answers:

  1. RaiseEvent
  2. DeclareEvent
  3. FireEvent
  4. DoEvents
  5. ExecuteEvents
  6. Execute
  7. TriggerEvent

68. A __________ control defaults to displaying the files in the current directory:

Answers:

  1. File List Box
  2. Dir List Box
  3. Drive List Box
  4. Combo Box
  5. Picture Box
  6. List Box
  7. Combo Box
  8. DataGrid

69. The settings for the Color properties in Visual Basic are indicated by:

Answers:

  1. Decimal Coding
  2. Octal Coding
  3. Hexadecimal Coding
  4. Binary Coding

70. What does the forms collection contain?

Answers:

  1. A list of all forms in a project
  2. A list of all hidden forms
  3. A list of all currently loaded forms
  4. A list of all visible forms
  5. All the child forms of an MDI application.

71. Which of the following will perform a direct execution of a Command object?

Answers:

  1. The Execute method
  2. The Prepare method
  3. The ExecDirect method
  4. The Open method
  5. The Exec method
  6. The ExecProcedure method
  7. None of the above

72. The _______ function enables a VB application to make use of the idle time and to respond periodically to events.

Answers:

  1. GetTime()
  2. TrapEvents()
  3. GetDate()
  4. DoEvents
  5. Kill
  6. Idle
  7. Events
  8. Call

73. Which property procedure is used to retrieve the value of a property?

Answers:

  1. Retrieve
  2. Get
  3. GetProperty
  4. Value
  5. RetrieveValue

74. Which method will you use to remove a form from the Screen but retain it in memory?

Answers:

  1. Show method
  2. Unload method
  3. Hide method
  4. CLS method
  5. Deactivate method

75. The Load & Activate events are associated with:

Answers:

  1. All controls
  2. Form
  3. Command button
  4. Image box
  5. TreeView control
  6. ListView control
  7. DataGrid
  8. ComboBox

76. Which events allow you to determine if a Control or Shift key was pressed by the user?

Answers:

  1. Click and KeyPress
  2. Click, KeyUp and KeyDown
  3. KeyUp and KeyDown
  4. KeyPress, KeyUp and KeyDown
  5. Click, KeyPress, KeyUp and KeyDown
  6. KeyPress and KeyUp

77. What you must do before making calls to an ActiveX DLL project in the same Project Group?

Answers:

  1. Compile the DLL
  2. Check the DLL is off in your project’s Reference List
  3. Make sure the DLL is the Startup Project
  4. Ensure that a Standard Exe form is included and is made the Startup Form.

78. In order to overlap the controls (say a command button) during design time, we use the ‘Send To Back’ or ‘Bring To Front’ option from the Edit menu. To change it dynamically (i.e. during program execution) we need to change:

Answers:

  1. Background color property
  2. Caption property
  3. ZOrder property
  4. AutoRedraw property
  5. SendtoBack property
  6. BringtoFront property
  7. Hide property
  8. Show property

79. The ____ function returns the numeric value from a string expression:

Answers:

  1. Val
  2. CStr
  3. Round
  4. Int
  5. Num

80. Name the only property supported by a collection?

Answers:

  1. Name
  2. Index
  3. Count
  4. Type
  5. Value
  6. None of the above

81. What do CurrentX and CurrentY return?

Answers:

  1. Current X and Y co-ordinates of mousepointer
  2. Current X and Y co-ordinates of cursor
  3. A String of X & Y
  4. Current x and y co-ordinates of the control

82. Variables that allow sharing of values across event procedures are called:

Answers:

  1. Form level variable
  2. Object variable
  3. Module level variable

83. Which event of a text box would you use for validating the data entered by the user?

Answers:

  1. Validate
  2. Validation
  3. Check
  4. Audit
  5. GotFocus
  6. Checkdata
  7. ValidateDate

84. Which of the following approaches to data modifications is the least efficient?

Answers:

  1. Updating through a cursor using a recordset
  2. A stored procedure
  3. An update statement prepared and executed
  4. An update statement executed directly
  5. Updating through a data control

85. The interval property of the Timer control specifies the time in:

Answers:

  1. Milliseconds
  2. Seconds
  3. Minutes
  4. Hours
  5. Either milliseconds or seconds

86. Which event occurs only once in the entire life cycle of an ActiveX control?

Answers:

  1. Initialize
  2. Resize
  3. Terminate
  4. WriteProperties
  5. InitProperties
  6. Activate
  7. None of the above

87. How can you keep the user from exiting a form by clicking the Close button?

Answers:

  1. Place code in the Terminate event
  2. Place code in the Unload event
  3. Place code in the QueryUnload event
  4. This can only be done by using the Windows API
  5. Place code in the Load event
  6. Place code in the Deactivate event
  7. None of the above

88. Which of the following are not properties of Command Button:

Answers:

  1. Caption
  2. Visible
  3. Multi-Line
  4. Font
  5. Tag
  6. Bold
  7. Enabled

89. Which of the following debug tools would you use to locate your current position in a series of embedded procedure calls?

Answers:

  1. Locals window
  2. Immediate window
  3. Watch window
  4. Callstack
  5. Debug object

90. You are creating an ActiveX component that raises user-defined errors. Which of the following statements correctly raises an error to the client with error number 20000?

Answers:

  1. Err.Raise vbObjectError + 20000
  2. Err.Number = 20000
  3. Err.Raise 20000
  4. Err.Raise vbObjectError,20000
  5. Err.Number 20000
  6. Error.Raise vbObjectError + 20000
  7. Error.Number 20000
  8. Error.Raise 20000

91. A prepared statement is:

Answers:

  1. Query text cached on the client
  2. Query text cached on the server
  3. Compiled query cached on the client
  4. Compiled query cached on the server
  5. A stored procedure
  6. None of the above

92. Which parameter of the WriteProperty method can be omitted but should be included to increase the efficiency of the control?

Answers:

  1. Name
  2. Value
  3. Caption
  4. PropBag
  5. DefaultValue
  6. Title
  7. Tag
  8. None of the above

93. A project group is a Project which:

Answers:

  1. Consists of several Programs
  2. Consists of several Applications
  3. Consists of Various Forms And Code Modules
  4. Consists of several Projects

94. The _______ method loads the form named ‘Form1’ in to memory and also displays it.

Answers:

  1. Load Form1
  2. Form1.Show
  3. Form1.Visible = True
  4. Unload Form1
  5. Form1.activate

95. You want to display the code and the description of an error. What would be the correct syntax?

Answers:

  1. Msgbox err.no & err.text
  2. Msgbox err.number & err.text
  3. Msgbox error.number & error.text
  4. Msgbox error.number & error.description
  5. Msgbox err.number & err.description
  6. Msgbox err.num & err.description
  7. Msgbox err.num & err.text
  8. None of the above

96. If the CancelError Property of the CommonDialog Box is set to true then which of the following statement is true:

Answers:

  1. A runtime error can result if the user clicks the cancel button
  2. A compile time error occurs
  3. The program executes without any error
  4. You need to carry out conditional compilation
  5. None of the above

97. How do you create a read only property in a form?

Answers:

  1. Create only a Property Set procedure
  2. Create only a Property Get procedure
  3. Create only a Property Let procedure
  4. Create both a Property Get and Property Let procedure
  5. Declare a public variable in the Declarations section of the form
  6. Declare a private variable in the Declarations section of the form
  7. Create both a Property Get and Property Set procedure

98. What is the purpose of the Class Builder add-in in Visual Basic:

Answers:

  1. To add classes to the current project
  2. To change the current project to a class based project
  3. To create new classes and define their properties, methods & events
  4. To draw out how the application model will look

99. Which three methods does the collection object support?

Answers:

  1. Let, Get, Set
  2. Load, Unload, Count
  3. Add, Remove, Item
  4. Add, Delete, Index
  5. Add, Remove, Sort
  6. Add, Remove, Count
  7. Add, Delete, Count
  8. Add, Set, Count

100. Labels do not respond to _____ and ______ events.

Answers:

  1. Got_Focus , Lost_Focus
  2. Click , DblClick
  3. Dragdrop , OLECompleteDrag
  4. Change, Link Error

101. The _______ method resets the contents of bound controls to their original values when the user clicks on the cancel button.

Answers:

  1. UpdateControls
  2. PaintPicture
  3. Refresh
  4. Resize
  5. Resync
  6. Restore
  7. Cancel
  8. Update

102. Which of the following is the only drag related event?

Answers:

  1. DragEnter
  2. DragLeave
  3. DragStart
  4. DragStop
  5. DragDrop
  6. BeginDrag
  7. EndDrag

103. You are creating an ActiveX component that raises user-defined errors. What is the valid range of error numbers that you can use for user-defined errors?

Answers:

  1. 1-1000
  2. 0-255
  3. 1-65535
  4. 0-1000
  5. 513-65535
  6. 1000-2000
  7. 10000-20000
  8. None of the above

104. Which of the following procedure types will execute when you assign a value to a property of an object?

Answers:

  1. Property Get
  2. Property Assign
  3. Property Let
  4. Property Set
  5. Public Sub

105. Which parameter of the Execute method of the Connection object returns the number of records that the operation affected?

Answers:

  1. RecordsAffected
  2. RowsAffected
  3. RecordsUpdated
  4. RowsOperated
  5. RecordsOperated

106. Which of the following statements forces inline error handling?

Answers:

  1. On Error GoTo linelabel
  2. On Error GoTo Inline
  3. On Error Stop
  4. On Error Resume Next
  5. On Error GoTo 0
  6. On Error Resume
  7. None of the above

107. Which of the following compiled elements does not run in process?

Answers:

  1. ActiveX EXE
  2. ActiveX DLL
  3. ActiveX Control
  4. MTS Component
  5. Standard DLL
  6. Standard Exe

108. Which of the following locking types will lock a recordset only during an Update process and not immediately when the data modifications are requested?

Answers:

  1. Pessimistic
  2. Update
  3. Optimistic
  4. Batch optimistic
  5. Read only
  6. Delayed locking

109. Which form event would you use to activate a pop-up menu when the user clicks the right mouse button?

Answers:

  1. Click
  2. MouseMove
  3. DragOver
  4. DragDrop
  5. MouseUp
  6. Mouse-popup
  7. ShowMenu

972 total views, 2 views today

Upwork General Programming

System Programming Test 2016

Published by:

1. Which of the following system calls can be used to send a message via a connected socket?

Answers:

  1. send
  2. sendto
  3. sendmsg
  4. write

2. Which of the following methods can be used as a communication mechanism between two unrelated processes?

Answers:

  1. A pipe using the pipe system call.
  2. A named pipe using the mknod system call.
  3. Named sockets.
  4. Signals.

3. Which of the following are true of Unix system calls?

Answers:

  1. System calls are executed in “User” context.
  2. The routine “malloc” which is used for allocating memory is a system call.
  3. A new file can be created using the “open” system call.
  4. If two processes are executing the “write” system call simultaneously, they are serialized by the operating system.
  5. The “read” system call will never be blocked.

4. Which of the following Linux commands can be used to identify the processes consuming maximum resources (CPU, Memory)?

Answers:

  1. ps
  2. top
  3. lsof
  4. vmstat

5. Which of the following signals are used by the Unix shell to implement job control?

Answers:

  1. SIGHUP
  2. SIGSTOP
  3. SIGCONT
  4. SIGINT

6. Which of the following environment variables specifies the shared library search path?

Answers:

  1. SHARED_LIBRARIES
  2. SHLIB_PATH
  3. LD_LIBRARY_PATH
  4. LIBRARIES

7. Which of the following statements are true?

Answers:

  1. “wc -l” can be used to count the number of lines in the input.
  2. “find . -name ‘*.txt’ -exec rm {} ;” removes all “.txt” files in the current directory hierarchy.
  3. “cc -x ” can be used to generate the assembler listing of the C program file.
  4. “set -x” can be used within a ksh shell script to generate listing of shell commands while they are being executed.

8. Which of the following utilities would you use on a standard Linux system to debug a running application?

Answers:

  1. gdb.
  2. ltrace.
  3. strace.
  4. ptrace.

9. Which of the following can be used to inspect the system call arguments of a Linux process?

Answers:

  1. strace
  2. gdb
  3. adb
  4. mdb

10. Which of the following methods can be used to allocate and use memory on a Unix system?

Answers:

  1. brk
  2. sbrk
  3. malloc
  4. calloc

11. Which of the following utilities is used to generate a core file of a process on Linux?

Answers:

  1. gdb
  2. strace
  3. gcore
  4. objdump

12. Which of the following can be used to debug the process “123” and program “test” on a Linux system?

Answers:

  1. adb test 123
  2. gdb test 123
  3. strace 123
  4. strace -f -p 123

13. If a process has locked a System V Semaphore and receives a SIGKILL signal, which of the following is true?

Answers:

  1. The process can catch the signal and drop the semaphore before terminating.
  2. The process terminates without releasing the semaphore.
  3. The semaphore is released if the process had specified SEM_UNDO during creation.
  4. The signal is deferred until the semaphore is released.

14. Which of the following gdb commands can be used to obtain the stack

trace of all the threads of a multi threaded program running on Linux?

Answers:

  1. bt
  2. ::stack
  3. $C
  4. thread apply all bt

15. Which of the following shell commands is useful in single stepping through a shell script?

Answers:

  1. set -x
  2. echo
  3. trap
  4. DEBUG

16. Which of the following utilities is used to search out regular expressions in the input?

Answers:

  1. cat
  2. grep
  3. head
  4. tail

17. What does the command “mknod temp p” do?

Answers:

  1. It creates a named pipe.
  2. It creates directory nodes “temp” and “p”.
  3. It creates pipes “temp” and “p”

18. Threads created via pthread_create need to first set up shared memory
using shmop before they can share data.

Answers:

  1. True
  2. False

19. What does the “open” system call return to the caller?

Answers:

  1. 0 on success and -1 on error.
  2. File descriptor.
  3. An integer greater than or equal to 0 on success and -1 on error.
  4. Always 0.

20. What is the effect of a process executing an unlink system call while another process has opened the same file?

Answers:

  1. The unlink system call will fail.
  2. The unlink system call will succeed and the other process will be terminated.
  3. The unlink system call will be blocked until the other process has closed all references to the file.
  4. The unlink system call will succeed.

21. Which of the following signals cannot be ignored by a process?

Answers:

  1. SIGHUP
  2. SIGINT
  3. SIGTERM
  4. SIGKILL

22. Ignoring the setup cost for each of the System V IPC mechanisms, which of the following is the most efficient?

Answers:

  1. System V, Messages.
  2. System V, Shared Memory
  3. System V, Semaphores
  4. Sockets

23. What command is used to list the shared libraries used by an executable?

Answers:

  1. ldconfig
  2. ld
  3. ldd
  4. ls

24. What does the following command do to the process with pid 12345?
“kill -9 12345”.

Answers:

  1. It sends the INT signal causing the process to be interrupted.
  2. It sends the STOP signal causing the process to be stopped.
  3. It sends the KILL signal causing the process to be killed.
  4. It sends the HUP singal causing the process to hangup.

25. Which of the following system calls is the most memory efficient method of reading a file?

Answers:

  1. readv
  2. read
  3. mmap
  4. fcntl

26. Which of the following commands generates a listing of the system calls being executed by a program on Solaris?

Answers:

  1. ltrace
  2. tusc
  3. strace
  4. truss

27. What is the effect of issuing a “$c” command at the adb prompt during a debugging session on a Solaris 9 system?

Answers:

  1. It generates a listing of the stack trace.
  2. It causes the debugger to continue.
  3. It drops to the shell.
  4. It prints the register contents.

28. Which of the following sequences prints all the second column fields of an input file “values.txt”?

Answers:

  1. awk “print $2” values.txt
  2. awk ‘{print $2}’ values.txt
  3. awk ‘{print #2}’ values.txt
  4. cut -2 values.txt

29. Which of the following system calls increases the process priority?

Answers:

  1. priority
  2. nice
  3. ulimit
  4. fcntl

30. Which of the following is true of Unix system calls?

Answers:

  1. System calls cannot be executed by regular users.
  2. System calls are executed in the user context.
  3. System calls are executed in the kernel context.
  4. System calls cause a process switch.

31. If a process is hung in the kernel context, sending it a SIGKILL will _____.

Answers:

  1. kill the process immediately.
  2. be ignored by the Operating System.
  3. be delivered when the process switches back to the user context.

32. The library routine printf does not use any system calls.

Answers:

  1. True.
  2. False.

33. Which of the following gcc compiler options turns on optimization?

Answers:

  1. optimize
  2. O
  3. Opt
  4. -S

34. Which of the following options of the compiler is turned on to generate additional debug information (like the source code) for debugging an application?

Answers:

  1. O
  2. S
  3. E
  4. g

35. Which of the following options specifies a non standard library path during linking?

Answers:

  1. -l
  2. -L
  3. -o
  4. -g

36. Which of the following shell operators redirects the standard input of the command being executed?

Answers:

  1. <
  2. >
  3. %
  4. @

37. Which library routine is used to translate the numeric system call error code to a human readable text error message?

Answers:

  1. sprintf
  2. exit
  3. error
  4. perror

38. Which of the following IPC message operations is performed to setup communication between arbitrary processes?

Answers:

  1. msgctl
  2. msgsnd
  3. msgrcv
  4. msgget

39. What is the effect of executing the following system call on the file “test.txt”?
open(“test.txt”, O_TRUNC)

Answers:

  1. The file is truncated to the nearest block size before returning.
  2. The file is created before returning.
  3. The file is opened.
  4. If test.txt exists, the file is truncated to 0 bytes before returning.

40. How does a programmer distinguish a child from its parent process following a fork system call?

Answers:

  1. The system call returns 0 to the child and 1 to the parent.
  2. The system call returns 0 to the parent and the pid of the parent to the child.
  3. The system call returns 0 to the child and the pid of the child to the parent.
  4. There is no way to distinguish a child from its parent.

41. Which of the following libraries provides the POSIX thread implementation on Solaris?

Answers:

  1. libpthread
  2. libthread
  3. libnptl
  4. libc

42. Which of the following IPC shared memory sequences is correct?

Answers:

  1. shmctl, shmat, shmdt
  2. shmget, shmat, shmdt
  3. shmctl, shmget, shmat, shmdt
  4. shmat, shmdt

43. How is the value of the shell environment variable IFS changed to comma (‘,’)?

Answers:

  1. IFS=’,’; export IFS
  2. $IFS=’,’; export IFS
  3. IFS=’,’; export $IFS
  4. $IFS=’,’

44. Which of the compiler options generates an assembler output file?

Answers:

  1. -O
  2. -a
  3. -S
  4. -g

45. What does the ‘-pg’ option of the Unix compiler do?

Answers:

  1. It turns on the profiling of the executable code.
  2. It generates an assembler listing of the code.
  3. It turns on the generation of the optimized code.
  4. It prints the different function call graphs.

46. Shared libraries increase an application’s disk size?

Answers:

  1. True.
  2. False.

47. Which of the following redirects the standard error output of a command to the log file “error.log”?

Answers:

  1. “2>error.log”
  2. “2
  3. “>error.log”
  4. “|error.log”

48. What are the typical system calls the Unix shell invokes when it
has to execute a new command?

Answers:

  1. open, read, close.
  2. open, fork, exec.
  3. ioctl.

49. Which system call is used to send a signal to another process?

Answers:

  1. signal
  2. kill
  3. socket
  4. ioctl

50. Which of the following commands can be used to generate a listing of all the shared libraries that an executable needs?

Answers:

  1. ld
  2. ldd
  3. ls
  4. ln

51. What is the default file descriptor used for the error outputs of a process?

Answers:

  1. 0
  2. 1
  3. 2
  4. -1

52. Which of the following commands can be used on a Linux system to kill process 8977 and all its children?

Answers:

  1. kill -term 8977
  2. kill -kill 8977
  3. kill -stop 8977
  4. kill -int 8977

53. Which of the following commands can be used on a Linux system to configure a network interface (card)?

Answers:

  1. ifconfig
  2. ipconfig
  3. netstat -c
  4. route

54. Which of the following commands can be used to list all the active TCP connections only on a Linux system?

Answers:

  1. netstat -r
  2. netstat -t
  3. iptables -L
  4. route

55. Which of the following ksh trap sequences causes the function ‘handler’ to be executed when the script exits?

Answers:

  1. trap handler EXIT
  2. trap EXIT handler
  3. set handler EXIT
  4. trap handler exit

56. How many bytes of a file of size 1023 will be read by the following piece of code?

char buf[256];

<snip>
while (read(fd, buf, 256)) {
/* Take some action */
}
<snip>

Answers:

  1. 1024
  2. 1023
  3. 0
  4. 768

57. What is the effect of setting the “sticky” bit on an application’s executable image?

Answers:

  1. It causes the system to load the program faster the next time it runs.
  2. It causes the system to fail all unlink system call requests on the image.
  3. It causes the system to preload the application’s image into the system RAM.
  4. It causes the system to grant the application owner’s privileges to other users if they try to run the application.

58. A C program “domath.c” utilizes the math library. Which of
the following commands correctly creates the corresponding executable
“domath”?

Answers:

  1. cc -o domath domath.c
  2. cc -o domath domath.c -L /usr/lib -lmath
  3. cc -o domath domath.c -lm
  4. cc -o domath domath.c -Lmath

59. Which of the following sequences creates a socket based connection for communication?

Answers:

  1. open, listen, accept
  2. open, accept, listen
  3. socket, connect, accept, listen
  4. socket, connect, listen, accept

60. What does the open system call return upon success?

Answers:

  1. A non zero value, which is the file descriptor.
  2. Zero.
  3. A positive integer which is the file descriptor.
  4. The pointer to the FILE structure of the open file.

61. If a process executes the following C code on a Linux system, what is the outcome?

<snip>
char *cp = 0, c = *cp;
<snip>

Answers:

  1. The process executes the code without errors.
  2. The process is killed with a SIGSEGV.
  3. The process is killed with a SIGBUS.
  4. The process is killed with a SIGKILL.

62. On Linux, the pthread_create interface does not use the fork system call to create threads.

Answers:

  1. True.
  2. False.

63. Which of the following shell parameters contains the return value of the previously executed shell command?

Answers:

  1. $*
  2. $$
  3. $?
  4. $!

64. Which of the following calls is used to initiate a socket connection to a target address?

Answers:

  1. socket
  2. connect
  3. accept
  4. listen

65. Which of the following gcc options can be used to generate a position independent code on a Linux system?

Answers:

  1. -pic
  2. +z
  3. -b
  4. -mshared

66. Which of the following commands can be used to list all the active TCP connections on a Linux system?

Answers:

  1. netstat -r
  2. netstat -t
  3. iptables -L
  4. route

67. What is the network byte order in Unix?

Answers:

  1. Little Endian
  2. Big Endian
  3. It is negotiated during connection.
  4. It is undefined.

68. Which of the following segments within the process address space are unique to each thread?

Answers:

  1. code.
  2. data.
  3. stack.
  4. bss.

69. How do threads created using pthread library share data between themselves efficiently?

Answers:

  1. They use one of the standard interprocess communication methods.
  2. They use sockets.
  3. They don’t need any special mechanism as they share the data segment.
  4. They use shared memory.

70. By convention, which of the following signals causes a daemon to reload its configuration?

Answers:

  1. SIGHUP
  2. SIGKILL
  3. SIGINT
  4. SIGCONT

71. Which of the following block sizes results in the best read/write performance for an IO intensive application?

Answers:

  1. 8192
  2. 4096
  3. 2048
  4. 1024

72. What is the name of the standard linker on Unix?

Answers:

  1. cc
  2. ldd
  3. ld
  4. ls

73. Which of the following is employed by the operating system to speed up file IO on a Solaris system.

Answers:

  1. Inode Cache
  2. DNLC
  3. Buffer Cache
  4. Page Cache

74. How is the stack trace of all the threads in a multi threaded Linux application obtained?

Answers:

  1. strace -f -p <procid>
  2. “backtrace” at the gdb prompt.
  3. “thread apply all ::stack” at the gdb prompt.
  4. “thread apply all backtrace” at the gdb prompt.

75. Which of the following creates an IPC message channel?

Answers:

  1. id = msgget(key, 0700|IPC_CREAT);
  2. id = msgget(key, 0700, IPC_CREAT);
  3. id = msgctl(key, 0700|IPC_CREAT);
  4. id = msgctl(key, IPC_CREAT, 0700);

76. Which of the following system calls can be used to get the metadata of a file?

Answers:

  1. open
  2. stat
  3. fcntl
  4. ioctl

77. Which of the following commands can be used to create a static (archive) library?

Answers:

  1. tar
  2. ar
  3. ld
  4. gcc

78. Which of the following system calls is specific to debugging?

Answers:

  1. truss
  2. fcntl
  3. strace
  4. ptrace

79. Which of the following commands can be used to compile a C file called “test.c” into an executable called “test”?

Answers:

  1. cc -o test test.c
  2. cc -g -S test.c
  3. cc test test.c
  4. cc -E test.c

80. Which of the following IO mechanisms allows greater performance to concurrent IO-intensive applications?

Answers:

  1. Memory Mapped IO
  2. Read Ahead
  3. Direct IO (Filesystem locking is skipped)
  4. Async IO.

81. What is the outcome of attempting an ioctl system call on a block device file?

Answers:

  1. The system returns ENOTTY.
  2. The ioctl succeeds and returns 0.
  3. The system returns EIO.
  4. The system returns ENXIO.

82. Which of the following system calls can be used to create device special files?

Answers:

  1. open
  2. mkfs
  3. touch
  4. mknod

83. If a process is terminated due to a SEGFAULT on a Solaris 9 system, what is the name of the core file that is created?

Answers:

  1. core
  2. corefile
  3. memdump
  4. coredump

84. Which of the following socket system calls creates a Unix Domain Socket connection?

Answers:

  1. socket(PF_UNIX, SOCK_STREAM, protocol)
  2. socket(PF_INET, SOCK_DGRAM, protocol)
  3. socket(PF_IPX, SOCK_RAW, protocol)
  4. socket(PF_LOCAL, SOCK_STREAM, protocol)

85. Which of the following system calls creates a named socket?

Answers:

  1. creat
  2. mknod
  3. bind
  4. socket

86. Which of the following shell operators is used to send the standard output of the first command to the standard input of the second command?

Answers:

  1. &
  2. ^
  3. >
  4. |

87. Which of the following C headers needs to be included for socket programming?

Answers:

  1. <socket.h>
  2. <sys/socket.h>
  3. <stdio.h>
  4. <stdlib.h>

88. Where are the DNS and search domains specified?

Answers:

  1. /etc/fstab
  2. /etc/nsswitch.conf
  3. /etc/resolv.conf
  4. /etc/hosts-

89. A process opens a file and forgets to close the file descriptor when it
exits. What is the result?

Answers:

  1. It results in a resource leak.
  2. The OS calls exit on behalf of the process before it terminates the process resulting in all the resources being reclaimed.
  3. The OS garbage collector recovers the descriptor.

90. If a write system call fails and if errno is set to EFAULT, what does it signify?

Answers:

  1. The system encountered an IO error while doing the write.
  2. The file descriptor was illegal.
  3. The write buffer is not legal.
  4. The file was removed by another process while this write was being attempted.

91. Which of the following commands can be used to install the native software package SOFTpkg on a Solaris system?

Answers:

  1. tar -xvf SOFTpkg
  2. swinstall -s `pwd` SOFTpkg
  3. rpm -i SOFTpkg
  4. pkgadd -d . SOFTpkg

902 total views, 2 views today

Upwork General Programming

Swift Test 2016

Published by:

1. Which of these is an appropriate syntax for dispatching a heavy operation to a background thread?

Answers:

  1. dispatch_async(DISPATCH_QUEUE_PRIORITY_BACKGROUND), { self.heavyOperation() })
  2. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), { self.heavyOperation() })
  3. DISPATCH_QUEUE_PRIORITY_BACKGROUND({ self.heavyOperation() })
  4. dispatch_async({ self.heavyOperation() })

2. Which is the wrong definition of a protocol in Swift?

Answers:

  1. protocol SomeProtocol { var first: Int{ get } }
  2. protocol SomeProtocol { var first: Int{ set } }
  3. protocol SomeProtocol { var first: Int { get set } }
  4. protocol SomeProtocol { var first: Int { get set } var second: Int { get } }

3. Which of the following structures has both computed and stored properties?

Answers:

  1. struct Rect { var origin = CGPointZero var center: CGPoint { get { // } set { // } } }
  2. struct Rect { var center: CGPoint { get { // } set { // } } }
  3. struct Rect { let origin = CGPointZero }
  4. struct Rect { var origin = CGPointZero var center: CGPointMake(0,0) }

4. What is the name of the Xcode generated header file used to import Swift classes into an Objective-C Class given a product module named Example?

Answers:

  1. ExampleSwift.h
  2. Example.Swift.h
  3. Example+Swift.h
  4. Example-Swift.h

5. Considering var index = UInt8.max, which of the following operation results to the value of zero for var index?

Answers:

  1. index = index &- 1
  2. index = index &+ 1
  3. index = index &* 1
  4. index = index &/ 255

6. Which of these is a valid syntax for iterating through the keys and values of a dictionary?
let dictionary = [keyOne : valueOne, keyTwo : valueTwo]

Answers:

  1. for (key, value) in dictionary { println(“Key: (key) Value: (value)”) }
  2. for (key, value) in enumerate(dictionary) { println(“Key: (key) Value: (value)”) }
  3. for (key, value) in (dictionary.keys, dictionary.values) { println(“Key: (key) Value: (value)”) }
  4. for (key, value) in dictionary.enumerate() { println(“Key: (key) Value: (value)”) }

7. All Swift classes must inherit from which root class?

Answers:

  1. Swift classes do not require a root class.
  2. NSObject
  3. @ObjC
  4. Root

8. What does a retainCount represent in ARC?

Answers:

  1. The current number of strong references to an object.
  2. The current number of instances of an object.
  3. The total number of objects currently being retained in memory.
  4. The total number of times an object has been allocated.

9. Which of these statements is a valid way to extend the capabilities of our theoretical class, MyClass to conform to protocol MyProtocol?

Answers:

  1. extension MyClass(MyProtocol) { }
  2. extension MyClass, prot MyProtocol { }
  3. extension MyClass: MyProtocol { }
  4. extension MyClass, MyProtocol { }

10. What is the name of the Swift language feature that Objective-C Blocks are translated into?

Answers:

  1. Lambda
  2. Callback
  3. Closure
  4. Selector

11. Which keyword is used on a function in an enumeration to indicate that the function will modify ‘self’?

Answers:

  1. modifier
  2. mutating
  3. mutable
  4. mod
  5. mut

12. Which is correct for Enumerations?

Answers:

  1. Enumerations can define initializers.
  2. Enumerations cannot conform to protocols.
  3. Enumerations cannot conform to protocols.

13. Which one creates a dictionary with a key type of Integer and value of String?

Answers:

  1. var dict:[Int: String] = [“one”:1]
  2. var dict: [Int: String] = [1:”one”]
  3. var dict: [String: Int] = [1:”one”]
  4. var dict = [“one”:1]

14. Which of these is a valid definition of a generic function that incorporates inout parameters in Swift?

Answers:

  1. func swap<T>(inout a: T, inout b: T) { let temp = a a = b b = temp }
  2. func swap<U,T>(inout a: U, inout b: T) { let temp = a a = b b = temp }
  3. func swap<U,T>( a: U, b: T) { let temp = a a = b b = temp }
  4. func swap<T>( a: T, b: T) { let temp = a a = b b = temp }

15. Which one is the correct keyword for defining a constant in Swift?

Answers:

  1. const
  2. contant
  3. final
  4. let
  5. def

16. If we have a class named MyClass with a nested enum called Status, declared like so:
class MyClass {
enum Status {
case On, Off
}
}
How would one indicate that a variable is an enum of type Status outside the context of MyClass?

Answers:

  1. var status: MyClass.Status = .On
  2. var status: Status = .On
  3. var status: MyClass<Status> = .On
  4. var status: MyClass(Status) = .On

17. Which of the following could be used to indicate the Function Type of the following function:
func joinStrings(stringOne: String, stringTwo: String) -> String {
return stringOne + stringTwo
}

Answers:

  1. func(String, String -> String)
  2. (String, String) -> String
  3. {String, String} -> String
  4. {String, String}(String)

18. Which of the following statements could be used to determine if a given variable is of String type?

Answers:

  1. if String.hierarchy(unknownVariable) { }
  2. if unknownVariable is String { }
  3. if unkownVariable: String { }
  4. if (String)unknownVariable { }

19. Which of these could be an appropriate protocol declaration in Swift?

Answers:

  1. @objc protocol someProtocal { optional var first: Int { get } }
  2. @objc protocol someProtocal { optional var first: Int { set } }
  3. protocol someProtocal { optional var first: Int { get } }
  4. protocol someProtocal { var first: Int { set } }

20. In context of a Swift subscript, which of the following is correct?

Answers:

  1. struct MyStruct { var myStr = [String]() subscript (index : Int) -> String{ get{ return myStr[index] } set{ myStr[index] = newValue } } }
  2. struct MyStruct { var myStr = [String]() subscript (index : Int) -> Int{ get{ return myStr[index] } set(newValue){ myStr[index] = newValue } } }
  3. struct MyStruct { var myStr = [String]() subscript (index : Int) -> String{ get(){ return myStr[index] } set(newValue){ myStr[index] = newValue } } }
  4. struct MyStruct { var myStr = [String] subscript (index : Int) -> String{ get(){ return myStr[index] } set(newValue){ myStr[index] = newValue } } }

21. What is used to import Objective-C files into Swift?

Answers:

  1. Objective-C classes are automatically imported.
  2. Objective-C classes are imported in the Swift file using the class.
  3. Objective-C classes are imported via a Bridging Header.
  4. Objective-C classes import themselves by declare @SwiftImportable.

22. What keyword is used to indicate a custom operator that will appear in between two targets, similar to the addition operator in this example?
var sum = 10 + 10

Answers:

  1. @inter
  2. between
  3. infix
  4. @center

23. What is the output of this segment of code ?
var x = 0

for index in 1…5 {
++x
}
println(“(x)”)

Answers:

  1. 0
  2. compile error
  3. 5
  4. 4

24. What is the name of the deinitializer in a Class declaration?

Answers:

  1. deinit
  2. dealloc
  3. release

25. Which is correct regarding Swift enumeration members when they are defined?

Answers:

  1. Members are assigned a default integer value.
  2. Members are assigned a random default integer value.
  3. Members are not assigned default integer values.

26. What type of object are Swift Structures?

Answers:

  1. Reference Type
  2. Memory Type
  3. Abstract Type
  4. Value Type

27. Which keyword in the context of a Switch statement is required to force the execution of a subsequent case?

Answers:

  1. fallthrough
  2. continue
  3. break
  4. return

28. What is the type of Swift Enumerations?

Answers:

  1. Reference type
  2. Class type
  3. Collection type
  4. Value type

29. Given that we have defined myChar like so :
let myChar: Character = “b”
Which code segment can be considered a complete Switch statement and will run without any error?

Answers:

  1. switch myChar { case “a”,”A”: println(“The letter A”) case “b”,”B”: println(“The letter A”) }
  2. switch myChar { case “a”: println(“The letter A”) }
  3. switch myChar { case “a”: case “A”: println(“The letter A”) default: println(“Not the letter A”) }
  4. switch myChar { case “a”,”A”: println(“The letter A”) default: println(“Not the letter A”) }

30. Can enumeration type have methods?

Answers:

  1. Enumerations can have methods associate with them.
  2. Enumerations can have only member values.

31. Which of these is an appropriate syntax for declaring a function that takes an argument of a generic type?

Answers:

  1. func genericFunction(argument: T<Generic>) { }
  2. func genericFunction<T>(argument) { }
  3. generic func genericFunction(argument: T) { }
  4. func genericFunction<T>(argument: T) { }

32. Which of these is not a valid property declaration in Swift?

Answers:

  1. final let x = 0
  2. final lazy let x = 0
  3. final lazy var x = 0
  4. final var x = 0

33. Which of the following declares a mutable array in Swift?

Answers:

  1. var x = [Int]
  2. let x = [Int]
  3. var x = [Int]()
  4. let x = [Int]()

34. Which one of the below functions definitions is wrong considering Swift language?

Answers:

  1. func haveChar(#string: String, character: Character) -> (Bool)
  2. func mean(numbers: Double…) -> Double
  3. func minMax(array: [Int]) -> (min: Int, max: Int)?
  4. func minMax(array: [Int]) -> (min: Int?, max: Int?)

35. Which keyword is used in Swift when we want a property of a class to initialize when it is accessed for the first time?

Answers:

  1. let
  2. var
  3. const
  4. lazy

36. Which is used for down casting?

Answers:

  1. as!
  2. is
  3. is?
  4. as?

37. What attribute can be used to allow a protocol to contain optional functions and to be used in ObjC?

Answers:

  1. objective_bridge
  2. ObjC
  3. _objc
  4. @objc

38. Which of the following types can be used use as raw value types for an enumeration?

Answers:

  1. Bool
  2. Array
  3. Int, String, Float
  4. Dictionary

39. Which keyword do you use to declare enumeration?

Answers:

  1. var
  2. enum
  3. struct
  4. case

40. When declaring an enumeration, multiple member values can appear on a single line, separated by which punctuation mark?

Answers:

  1. Semi-colon
  2. Colon
  3. Comma
  4. Slash
  5. Point

3,440 total views, 10 views today

Upwork General Programming

Python Test 2016

Published by:

1. Which of the following will disable output buffering in Python?

Answers:

  1. Using the -u command line switch
  2. class Unbuffered: def __init__(self, stream): self.stream = stream def write(self, data): self.stream.write(data) self.stream.flush() def __getattr__(self, attr): return getattr(self.stream, attr) import sys sys.stdout=Unbuffered(sys.stdout)
  3. Setting the PYTHONUNBUFFERED environment variable
  4. sys.stdout = os.fdopen(sys.stdout.fileno(), ‘w’, 0)

2. Which of the following members of the object class compare two parameters?

Answers:

  1. object.__eq__(self, other)
  2. object.__ne__(self, other)
  3. object.__compare__(self, other)
  4. object.__equals__(self, other)
  5. object.__co__(self, other)
  6. None of these

3. Object is the base class of new-style datatypes. Which of the following functions is not a member of the object class?

Answers:

  1. object.__eq__(self, other)
  2. object.__ne__(self, other)
  3. object.__nz__(self)
  4. object.__repr__(self)
  5. None of these

4. In Python, what is the default maximum level of recursion?

Answers:

  1. 500
  2. 1000
  3. 10000
  4. There is no default maximum level

5. Various email and news clients store messages in a variety of formats, many providing hierarchical and structured folders. Which of the following provides a uniform API for reading the messages stored in all the most popular folder formats?

Answers:

  1. mailstruct
  2. emailarch
  3. emailfolders
  4. mailbox

6. Which of the following are the main features of Python?

Answers:

  1. Cross-platform
  2. Extensible
  3. Object-oriented, with multiple inheritance
  4. Written in Java
  5. Overloading of common operators
  6. All of these

7. Which of the following variables store parameters passed from outside?

Answers:

  1. sys.param
  2. sys.arg
  3. sys.argv
  4. sys.prm

8. Which of the following functions can change the maximum level of recursion?

Answers:

  1. setmaxrecursion function in the sys module
  2. setrecursionlimit function in the sys module
  3. setmaximumrecursion function in the sys module
  4. None of these

9. Read the following statements:

>>> import array
>>> a = array.array(‘c’,’spam and eggs’)
>>> a[0] = ‘S’
>>> a[-4:] = array.array(‘c’,’toast’)
>>> print ”.join(a)

Which of the following will be the output of the above code snippet?

Answers:

  1. Spam and toast
  2. spam and toast
  3. Spam and eggs
  4. spam and eggs
  5. spamandtoast
  6. spamandeggs

10. How can a numeric String (eg. “545.2222”) be converted to Float or Integer?

Answers:

  1. import string parseStr = lambda x: x.isalpha() and x or x.isdigit() and (x) or x.isalnum() and x or len(set(string.punctuation).intersection(x)) == 1 and x.count(‘.’) == 1 and float(x) or x parseStr(“545.2222”)
  2. def convert(n): try: return int(n) except ValueError: return float(n + 0.5) convert(“545.2222”)
  3. a = “545.2222” float(a) int(float(a))
  4. def parseIntOrFloat(s): return eval(s)

11. Which of the following is the correct prototype of the string.find() function?

Answers:

  1. string.find(s, sub ,start ,end)
  2. string.find(s, sub ,start [,end])
  3. string.find(s, sub [,start [,end]])
  4. string.find(s, sub [,start] ,end)

12. It is possible to use encoding other than ASCII in Python source files. The best way to do it is to put one more special comment line right after the #! line to define the source file encoding. Which of the following is the correct statement to define encoding?

Answers:

  1. coding: iso-8859-15
  2. # -*- iso-8859-15 -*-
  3. # -*- coding: iso-8859-15 -*-
  4. None of these

13. How can a null object be declared in Python?

Answers:

  1. none
  2. None
  3. null
  4. Null

14. Which of the following modules lets you check whether two files are identical, and whether two directories contain some identical files?

Answers:

  1. dircomp
  2. filecompare
  3. filecmp
  4. structcomp

15. Which function could be used to list every file and folder in the current directory?

Answers:

  1. os.dirnames(‘.’)
  2. os.listdir(‘.’)
  3. os.listdir(‘/’)
  4. os.ls()

16. The core text processing tasks in working with email are parsing, modifying, and creating the actual messages. Which of the following modules deal with parsing and processing email messages?

Answers:

  1. MimeWriter
  2. mimify
  3. Both MimeWriter and mimify
  4. Neither MimeWriter nor mimify

17. Which of the following is the correct prototype for the ‘open’ function of the file class in python 2.2+?

Answers:

  1. open(fname [,mode [,buffering]])
  2. open(fname [,buffering [,mode]])
  3. open(fname [,mode])
  4. open(fname,mode,buffering)
  5. open(fname,buffering,mode)
  6. None of these

18. Which user input method will act like a file-object on which read and readline functions can be called?

Answers:

  1. sys.stdin
  2. raw_input()
  3. input()
  4. sys.argv

19. Which of the following protocol libraries can be used for an email implementation in a Python application?

Answers:

  1. telnetlib
  2. smtplib
  3. ftplib
  4. None of these

20. Which of the following statements imports every name in a module namespace into the current namespace?

Answers:

  1. from modname import All
  2. from modname import *
  3. from modname import ?
  4. from modname import All as *

21. Which is the correct way to remove an installed Python package?

Answers:

  1. easy_install -v <package>
  2. pip uninstall <package>
  3. easy_install -u <package>
  4. pip -m <package>

22. One common way to test a capability in Python is to try to do something, and catch any exceptions that occur.
Which of the following is the correct mechanism of trapping an error?

Answers:

  1. try: code to be verified will come here exception <except>:
  2. try: code to be verified will come here except <exception>:
  3. try: code to be verified will come here exception:
  4. try: code to be verified will come here exception <exception>:

23. Which of the following is the correct way to get the size of a list in Python?

Answers:

  1. list.length()
  2. len(list)
  3. sizeof(list)
  4. list.size()

24. What will be the output of the following statements:

>>> import string
>>> string.ljust(width=30,s=”Mary had a little lamb”)

Answers:

  1. ‘Mary had a little lamb ‘
  2. ‘Mary had a little lamb’
  3. ‘ Mary had a little lamb’
  4. None of these

25. The most important element of the email package is the message. The email class provides the classes for messages in Python. Which of the following classes is used for the message?

Answers:

  1. email.Message
  2. email.message.Message
  3. email.messages
  4. email.emailmessage

26. Consider the function:

def hello():
return “Hello, world!”

Which of the following is the correct way to make a decorator that could be used to make hello() return “#Hello, world!#”?

Answers:

  1. def hello(): return “#Hello, world!#”
  2. def hashes(fn): def wrapped(): return “#” + fn() + “#” return wrapped @hashes def hello(): return “Hello, world!”
  3. def hashes(fn): def wrapped(): return “#” + “#” return wrapped @hashes def hello(): return “Hello, world!”
  4. def hashes(fn): def wrapped(): print “#” + fn() + “#” return @hashes def hello(): return “Hello, world!”

27. Object is the base class of new-style datatypes. Which of the following functions is not a member of the object class?

Answers:

  1. object.__eq__(self, other)
  2. object.__notequal__(self, other)
  3. object.__repr__(self)
  4. None of these

28. Which of the following modules keep prior directory listings in the memory to avoid the need for a new call to the file system?

Answers:

  1. sys
  2. FileSys
  3. dirsys
  4. dircache

29. Which of the following modules is used internally to determine whether a path matches?

Answers:

  1. dircmp
  2. filecompare
  3. fncmp
  4. fnmatch

30. Examine the following prototype for the ‘open’ function of the file class in Python 2.2+:

open(fname [,mode [,buffering]])

Which of the following is correct for the ‘buffering’ argument?

Answers:

  1. 0 for none
  2. 1 for line oriented
  3. An integer larger than 1 for number of bytes
  4. All of these

31. Which of the following statements copy the contents of a list and not just a reference to the list?

Answers:

  1. newlist = oldlist
  2. newlist = oldlist[:]
  3. newlist = oldlist(dummy)
  4. None of these

32. Which of the following functions is used to send audio data via the Internet?

Answers:

  1. email.MIMEAudio(audiodata [,subtype [,encoder [,**params]]])
  2. email.SendAudio(audiodata [,subtype [,encoder [,**params]]])
  3. email.MIMEAudio.MIMEAudio(audiodata [,subtype [,encoder [,**params]]])
  4. email.MIMEAudio.SendAudio(audiodata [,subtype [,encoder [,**params]]])

33. Read the following statements:

Statement 1: A simple assignment statement binds a name into the current namespace, unless that name has been declared as global.
Statement 2: A name declared as global is bound to the global (module-level) namespace.

Which of the following is correct?

Answers:

  1. Statement 1 is true, but statement 2 is false.
  2. Statement 2 is true, but statement 1 is false.
  3. Both statements are true.
  4. Both statements are false.

34. Which of the following commands would produce the following result:
result: ‘line 1nline 2’

Answers:

  1. result = ‘nline 1nline 2n’.rstrip()
  2. result = ‘nline 1nline 2n’.split()
  3. result = ‘nline 1nline 2n’.strip()
  4. result = ‘nline 1nline 2n’.lstrip()
  5. result = ‘nline 1nline 2n’.splitlines()

35. Which is not used to install Python packages?

Answers:

  1. easy_install
  2. pip
  3. distribute
  4. installtools

36. Which of the following exceptions occurs while importing a module?

Answers:

  1. ModuleError
  2. ImportError
  3. ImportModuleError
  4. ReferenceError

37. Which of the following statements can be used to remove an item from a list by giving the index?

Answers:

  1. remove listname[index]
  2. del listname[index]
  3. kill listname[index]
  4. None of these

38. Read the following statements:

>>> word = ‘Help’ + ‘A’
>>> ‘<‘ + word*5 + ‘>’

Which of the following will be the output of the above code snippet?

Answers:

  1. ‘<HelpAHelpAHelpAHelpAHelpA>’
  2. ‘<HelpA5>’
  3. ‘<HelpA*5>’
  4. An error
  5. None of these

39. The least sophisticated form of text output in Python is writing to open files. In particular, which of the following streams can be used?

Answers:

  1. STDOUT
  2. STDERR
  3. STDPRN
  4. STDFIL

40. Which of the following options are true regarding these two code samples?
Code sample 1:
def main():
for i in xrange(10**8):
pass
main()

Code sample 2:
for i in xrange(10**8):
pass

Answers:

  1. Code sample 2 would take a longer time to complete than code sample 1. This is because in code sample 1, ‘i’ is local, whereas in code sample 2 it is global.
  2. Code sample 1 would take a longer time to complete than code sample 2. This is because code sample 1 would take additional time in defining and calling the function.
  3. Code sample 2 would take less time to complete because Python is able to detect pass as a null operation, and skip the whole loop.
  4. None of these.

41. How many arguments can a print statement handle?

Answers:

  1. One
  2. Any number of string arguments only
  3. Any number of numeric arguments only
  4. Any number of string or numeric arguments

42. When is the “yield” keyword used in Python?

Answers:

  1. When other processes need to take precedence over the Python script
  2. To break out of a loop
  3. When a function needs to return a list that only needs to be read through once
  4. Never

43. What is the best way to check if the object ‘myobject’ is iterable in Python?

Answers:

  1. myobject.isIter()
  2. try: [ e for e in myobject] except TypeError: print myobject, ‘is not iterable’
  3. try: iter.myobject except: print myobject, ‘is not iterable’
  4. if [ e for e in myobject]: print myobject, ‘is iterable’ else: print myobject, ‘is not iterable’

44. In Python, built-in exceptions can be inherited from. Which of the following is the base exception class?

Answers:

  1. Exceptions
  2. BaseException
  3. Exception
  4. Except

45. Given a program that saved a text file in the directory “/temp_files”, which of the following will make sure that “/temp_files” exists before writing the file?

Answers:

  1. d = os.path.dirname(“/temp_files”) if not os.path.exists(d): os.makedirs(d)
  2. d = os.path(“/temp_files”) if not os.path(d): os.makedirs(d)
  3. d = os.path.dirname(“/temp_files”) if os.path.exists(d): os.makedirs(d)
  4. if not os.path.exists(“/temp_files”): os.makedirs(d)

46. Read the following statements:

>>> lst = [‘spam’,’and’,’eggs’]
>>> lst[2] = ‘toast’
>>> print ”.join(lst)
>>> print ‘ ‘.join(lst)

Which of the following is the output of the second print statement in the above code snippet?

Answers:

  1. spam and eggs
  2. spamandeggs
  3. spamandtoast
  4. spam and toast

47. Read the following statements:

>>> import string
>>> s = ‘mary11had a little lamb’
>>> print s

Which of the following will be the output of the above code snippet?

Answers:

  1. mary had a little lamb
  2. mary11 had a little lamb
  3. mary had a little lamb
  4. mary11had a little lamb

48. Read the following statements:

Statement 1: Many string module functions are now also available as string object methods.
Statement 2: To use string object methods, there is no need to import the string module.

Which of the following is correct?

Answers:

  1. Statement 1 is true, but statement 2 is false.
  2. Statement 2 is true, but statement 1 is false.
  3. Both statements are true.
  4. Both statements are false.

49. What would the ‘sorted_tel’ be in the following code:
tel = {‘jack’: 4098, ‘sape’: 5139, ‘bill’: 3678, ‘mike’: 2122}
sorted_tel = sorted(tel.items(), key=lambda x: x[1])

Answers:

  1. A dictionary sorted by the second element.
  2. A list of Tuples sorted by the second element.
  3. A list of dictionaries sorted by the first element.
  4. A dictionary sorted by the first element.
  5. A list of Tuples sorted by the first element.

50. Inheriting from a base class enables a custom class to use a few new capabilities, such as slots and properties. Which of the following is the base class of new-style datatypes?

Answers:

  1. base
  2. object
  3. dict
  4. custom
  5. None of these

51. How can a list be split into equal sized chunks?

Answers:

  1. f = lambda x, n, acc=[]: f(x[n:], n, acc+[(x[:n])]) if x else acc
  2. def chunks(l, n): for i in xrange(0, len(l), n): yield l[i:i+n]
  3. def split_seq(seq, num_pieces): start = 0 for i in xrange(num_pieces): stop = start + len(seq[i::num_pieces]) yield seq[start:stop] start = stop
  4. chunks = lambda l, n: [l[x: x+n] for x in xrange(0, len(l), n)] chunks(l, 10)

52. Writing to STDOUT and STDERR is fairly inflexible, and most of the time the print statement accomplishes the same purpose more flexibly. How many arguments can a print statement handle?

Answers:

  1. 1
  2. 2
  3. 7
  4. Any number

53. Which of the following is the best way to reverse the string ‘Test String’ in Python?

Answers:

  1. string.reverse(‘Test String’)
  2. ‘Test String'[::-1]
  3. reversed(‘Test String’)
  4. ‘Test String'[-1:0]

54. What is the result of the following code:
>>> import itertools
>>> x = itertools.count(0)
>>> x.__class__.__name__

Answers:

  1. Nothing
  2. ‘count’
  3. ‘Object’
  4. ‘None’

55. What is the most flexible way to call the external command “ls -l” in Python?

Answers:

  1. from subprocess import call call([“ls”, “-l”])
  2. from subprocess import call call(“ls -l”)
  3. os.system(“ls -l”)
  4. os.system([“ls”], [“-l”])

56. Which of the following is the correct method for changing a global variable inside a function?

Answers:

  1. def change_globvar(): globvar = 1
  2. def change_globvar(): global globvar globvar = 1
  3. def change_globvar(): import globvar globvar = 1
  4. def change_globvar(): global globvar = 1

57. Which list flattening method will have the shortest running time?

Answers:

  1. l = [ [1, 2, 3], [4, 5, 6], [7], [8, 9] ] * 99 import itertools list( itertools.chain.from_iterable( l ) )
  2. l = [ [1, 2, 3], [4, 5, 6], [7], [8, 9] ] * 99 reduce( lambda x, y: x + y, l )
  3. l = [ [1, 2, 3], [4, 5, 6], [7], [8, 9] ] * 99 sum( l, [ ] )
  4. l = [ [1, 2, 3], [4, 5, 6], [7], [8, 9] ] * 99 [ item for sublist in l for item in sublist ]

58. Which of the following is the correct way to flush output of Python print?

Answers:

  1. import sys sys.stdout.flush()
  2. class flushfile(file): def __init__(self, f): self.f = f def write(self, x) self.f.write(x) self.f.flush() import sys sys.stdout = flushfile(sys.stdout)
  3. import sys sys.stdout = os.fdopen(sys.stdout.fileno(), ‘w’, 0)
  4. Running python with the -u command-line switch

59. Which of the following is the best method to find the indices of all occurances of a word in a string?

line = ‘mary had a little lamb, little lamb, little lamb’
word = ‘lamb’

Answers:

  1. import re indices = [occurance.start() for occurance in re.finditer(word, line)]
  2. def find_all(line, word): start = 0 while True: start = line.find(word, start) if start == -1: return yield start start += len(word) indices = list(find_all(line, word))
  3. indices = [i – 1 for i in range(len(line)) if line.startswith(word, i – 1)]
  4. None of these

60. In Python 2.x, which of the following is the way to check to make sure that the variable ‘x’ is not a string?

Answers:

  1. assert isinstance(x, basestring)
  2. assert not isinstance(x, basestring)
  3. assert not instance(x, basestring)
  4. assert not x.isinstance(basestring)

61. Which of the following will throw an exception in Python?

Answers:

  1. call Exception(“Here is an Exception!”)
  2. throw Exception(“Here is an Exception!”)
  3. raise Exception(“Here is an Exception!”)
  4. create Exception(“Here is an Exception!”)

62. Which of the following functions modifies the list in place to indicate which items are directories, and which are plain files?

Answers:

  1. dircache.listdir(path, lst)
  2. dircache.annotate(path, lst)
  3. dircache.filter(path, lst)
  4. dircache.scan(path, lst)

63. Which Python module can be used for copying files?

Answers:

  1. util
  2. shutil
  3. copy
  4. filecopy

64. Which of the following statements are true?

A. ._variable is semi-private and meant just for convention.
B. .__variable is considered superprivate and gets name mangled to prevent accidental access.
C. .__variable__ is typically reserved for built-in methods or variables.

Answers:

  1. A
  2. B
  3. C
  4. A, B, and C

65. How can an element be removed from a list using its list index?

Answers:

  1. myList.remove(index)
  2. pop myList[index]
  3. del myList[index]
  4. myList.delete(index)

66. Which of the following is the correct way to check to see if the variable theVar is an integer?

Answers:

  1. isinstance(theVar, int)
  2. theVar.isinstance(int)
  3. int.isinstance(theVar)
  4. is(theVar, int)

67. Which of the following is the base class for new-style file objects?

Answers:

  1. base
  2. file
  3. fileobject
  4. filebase

68. Which of the following methods returns the ASCII value of a character in Python?

Answers:

  1. ascii
  2. ord
  3. asciicode
  4. None of these

69. What is the output of the following code:

name = ‘Jon’
name.rjust(4, ‘A’)

Answers:

  1. ‘Jon A’
  2. ‘A Jon’
  3. ‘AJon’
  4. ‘JonA’

70. Which of the following is a way to find a local computer’s IP address with Python?

Answers:

  1. import socket socket.gethostbyname(socket.gethostname())
  2. socket.gethostbyname(socket.gethostname())
  3. import socket gethostbyname(socket.gethostname())
  4. import ifconfig print (ifconfig -a)

71. What is a metaclass in Python?

Answers:

  1. A class that is inherited from
  2. A class that inherits from another class
  3. Something that can be attached to any class, that gives it a constant set of attributes
  4. Something that creates “class” objects

72. Which of the following is the correct way to call the private method, myPrivateMethod(), in class MyClass, using dir(obj)?

class MyClass:
def __myPrivateMethod(self):
print “Private Method”

obj = MyClass()
print dir(obj)

Answers:

  1. __myPrivateMethod
  2. _MyClass__myPrivateMethod
  3. myPrivateMethod
  4. A private method will not be shown in the output.

73. What is the output of the following code?

def foo(param1, *param2):
print param1
print param2

def bar(param1, **param2):
print param1
print param2

foo(1,2,3,4,5)
bar(1,a=2,b=3)

Answers:

  1. TypeError: foo() got multiple values for keyword argument ‘param1’
  2. 1 (2, 3, 4, 5) 1 (2, 3)
  3. 1 (2, 3, 4, 5) 1 {‘a’: 2, ‘b’: 3}
  4. 1 {2, 3, 4, 5} 1 (‘a’: 2, ‘b’: 3)

74. Which of the following is the correct way to execute a program from inside Python without having to consider how the arguments/quotes are formatted?

Answers:

  1. import subprocess subprocess.call(‘C:\Temp\a b c\Notepad.exe’, ‘C:\test.txt’)
  2. os.call([‘C:\Temp\a b c\Notepad.exe’, ‘C:\test.txt’])
  3. import subprocess subprocess.call([‘C:\Temp\a b c\Notepad.exe’, ‘C:\test.txt’])
  4. subprocess.call([‘C:\Temp\a b c\Notepad.exe’, ‘C:\test.txt’])

75. What is the correct way to delete a directory that is not empty using Python?

Answers:

  1. os.remove(‘/directory’)
  2. os.rmtree(‘/directory’)
  3. shutil.rmtree(‘/directory’)
  4. import shutil shutil.rmtree(‘/directory’)

76. Which of the following is the correct way to write a generator which will output the numbers between 1 and 100 (inclusive)?

Answers:

  1. def onehundred(start, end): current = start while current <= end: yield current current += 1 for x in onehundred(1, 100): print x
  2. def onehundred(start, end): current = start while current <= end: return current current += 1 for x in onehundred(1, 100): print x
  3. def onehundred(start, end): current = start while current <= end: yield current current += 2 for x in onehundred(1, 100): print x
  4. def onehundred(start, end): while current <= end: yield current current += 1 for x in onehundred(1, 100): print x

77. Which of the following code snippets concatenates the list a_list = [1, 2, 3] with the tuple a_tuple = (4, 5), so the result would be [1, 2, 3, 4, 5]?

Answers:

  1. a_list + a_tuple
  2. a_list.extend(a_tuple)
  3. a_list.append(a_tuple)
  4. a_list.append(*a_tuple)

78. Which of the following will determine the number of CPUs available in the operating environment?

Answers:

  1. import os os..cpu_count()
  2. import sys sys..cpu_count()
  3. import psutil sutil.NUM_CPUS
  4. import multiprocessing multiprocessing.cpu_count()

3,980 total views, 13 views today

Upwork General Programming

Programming with C Test 2016

Published by:

1. Which of the following statements will result in a compilation error?

Answers:

  1. int n=5, x; x=n++;
  2. int n=5, x; x= ++n++;
  3. int n=5, x; x= (n+1)++;
  4. int n=5, x=6; x= (n+x)++;
  5. None of the above

2. Read the following two declaration statements.

1. #include <stdio.h>
2. #include “stdio.h”

Which of the following statements pertaining to the above two statements are correct?

Answers:

  1. For statement 1, the header file will be searched first in the local directory and then in the standard system directories such as “/usr/include”
  2. For statement 1, the header file will be searched in the standard system directories such as “/usr/include”
  3. For statement 2, the header file will be searched first in the local directory and then in the standard system directories such as “/usr/include”
  4. For statement 2, the header file will be searched in the standard system directories such as “/usr/include”
  5. None of the above

3. Which of the following statements are correct for the keyword register?

Answers:

  1. It is a storage-class-specifier
  2. It guarantees that the variable is kept in the CPU register for maximum speed
  3. It requests that the variable be kept in the CPU register for maximum speed
  4. It does not guarantee that the variable value is kept in CPU register for maximum speed

4. Which is/are the type/s of memory allocation that needs/need the programmer to take care of memory management?

Answers:

  1. Static memory allocation
  2. Dynamic memory allocation
  3. Automatic memory allocation
  4. Memory allocation on stack
  5. Memory allocation on heap

5. Which of the following comparison statements will be true if an integer is 16 bits and a long is 32 bits on a machine?

Answers:

  1. -1L < 1U
  2. -1L > 1U
  3. -1L < 1UL
  4. -1L > 1UL

6. Which of the following is the correct way of initializing a two-dimensional array?

Answers:

  1. char str[2][4]={ “abc”, “def” };
  2. char str[2][4]={ {“abc”}, {“def”} };
  3. char str[2][4]={ {‘a’,’b’,’c’,”}, {‘d’,’e’,’f’,”} };
  4. a and b
  5. a, b and c

7. Given the array:
int num[3][4]= {
{3,6,9,12},
{15,25,30,35},
{66,77,88,99}
};
what would be the output of *(*(num+1)+1)+1?

Answers:

  1. 3
  2. 15
  3. 26
  4. 66
  5. 77

8. Which function will you use to write a formatted output to the file?

Answers:

  1. fputc()
  2. fputs()
  3. fprintf()
  4. fseek()
  5. ftell()

9. Given the array:
int num[3][4]=
{
{3,6,9,12},
{15,25,30,35},
{66,77,88,99}
};

what would be the output of *(*(num+1))?

Answers:

  1. 3
  2. 15
  3. 66
  4. 6
  5. 25

10. What would be printed on the standard output as a result of the following code snippet?

main()
{
char option = 5;
switch(option)
{
case ‘5’:
printf(“case : 1 n”);
break;
case 5:
printf(“case : 2 n”);
break;
default:
printf(“case : 3 n”);
break;
}
return 0;
}

Answers:

  1. case : 1
  2. case : 2
  3. case : 3
  4. Result in compilation error
  5. None of the above

11. What would be printed on the standard output as a result of the following code snippet?

main()
{
int i=5;
char option = 5;
switch(option)
{
case ‘5’:
printf(“case : 1 n”);
break;
case i:
printf(“case : 2 n”);
break;
default:
printf(“case : 3 n”);
break;
}
return 0;
}

Answers:

  1. case : 1
  2. case : 2
  3. case : 3
  4. Result in compilation error
  5. None of the above

12. What would be printed on the standard output as a result of the following code snippet?

#define func(t, a, b) { t temp; temp=a; a=b; b=temp; }
main()
{
int a=3, b=4;
float c=4.5, d = 5.99;
func(int, a, b);
func(float, c, d);
printf(“%d %d “, a, b);
printf(“%.2f %.2fn”, c, d);
}

Answers:

  1. Results in Compilation Error
  2. 3 4 5.99 4.50
  3. 3 4 4.50 5.99
  4. 4 3 5.99 4.50
  5. None of the above

13. What would be printed on the standard output as a result of the following code snippet?

main()
{
void addup (int b);
addup(b);
return 0;
}
int b = 5;
void addup (int b)
{
static int v1;
v1 = v1+b;
printf(“%d “, v1);

}

Answers:

  1. Will result in Compilation Error
  2. 5
  3. 0
  4. Undefined value

14. Given the following array declaration:

int a[2][3][4];
what would be the number of elements in array a?

Answers:

  1. 24
  2. 22
  3. 20
  4. 12
  5. 36

15. Which file header is to be included for file handling in a C program?

Answers:

  1. string.h
  2. file.h
  3. stdio.h
  4. stdlib.h
  5. ctype.h

16. What is the return type of the following function declaration?
func(char c);

Answers:

  1. void
  2. char
  3. int
  4. undefined

17. What is the return value in case a file is not opened successfully by using fopen()?

Answers:

  1. 0
  2. 1
  3. 100
  4. NULL

18. What is the function to concatenate two strings?

Answers:

  1. strcmp()
  2. strcpy()
  3. strcat()
  4. strlen()
  5. catstr()

19. Which of the following statements is valid and correct?

Answers:

  1. char amessage[] = “lmnop”; amessage++;
  2. char *pmessage = “abcde”; (*pmessage)++;
  3. char amessage[] = “lmnop”; (*amessage)++;
  4. char *pmessage = “abcde”; pmessage++;

20. What will be the output of following code?

int main()
{
int i;
i = 0;
for (i = 1; i <2; i++)
{
i++;
printf( “%d”, i );
continue;
printf( “%d”, i );
}
return 0;
}

Answers:

  1. 22
  2. 2,2
  3. 2
  4. none of the above

21. Which of the following is not a valid mode for opening a file?

Answers:

  1. r
  2. w
  3. a
  4. r+
  5. i

22. Given the following array:

char books[][40]={
“The Little World of Don Camillo”,
“To Kill a Mockingbird”,
“My Family and Other Animals”,
“Birds, Beasts and Relatives”
};
what would be the output of printf(“%c”,books[2][5]);?

Answers:

  1. m
  2. M
  3. F
  4. i
  5. L

23. What would be printed on the standard output as a result of the following code snippet?

char *str1 = “Hello World”;
strcat(str1, ‘!’);
printf(“%s”, str1);

Answers:

  1. Hello World!
  2. Hello World
  3. Hello
  4. The code snippet will throw a compilation error

24. What will be printed on the standard output as a result of the following code snippet?

void main()
{
char arr[] = {‘R’,’A’,’M’,”};
printf(“%d”,strlen(arr));
}

Answers:

  1. 0
  2. 1
  3. 3
  4. 4
  5. Cannot be determined

25. Given the following array:

int a[8] = {1,2,3,4,5,6,7,0};
what would be the output of
printf(“%d”,a[4]); ?

Answers:

  1. 3
  2. 4
  3. 5
  4. 6
  5. 7

26. In order to read structures/records from a file, which function will you use?

Answers:

  1. fscanf()
  2. fread()
  3. fgets()
  4. fgetc()
  5. fseek

27. An array is defined with the following statement in a file, file1.c

int a[ ] = { 1, 2, 3, 4, 5, 6 };

In another file, file2.c, the following code snippet is written to use the array a:

extern int a[];
int size = sizeof(a);

What is wrong with the above code snippet?

Answers:

  1. The size of the operator cannot be applied to an array
  2. There is nothing wrong with the code snippet. The value of the size will be 6
  3. There is nothing wrong with the code snippet. The value of the size will be 7
  4. An extern array of unspecified size is an incomplete type. The size of the operator during compile time is unable to learn the size of an array that is defined in another file
  5. None of the above

28. What would be printed on the standard output as a result of the following code snippet?

main()
{
char *s=”Hello World”;
char s1[20], s2[20];
int len = sscanf(s,”%s”,s1);
printf(“%s : %d”, s1, len);
}

Answers:

  1. Compilation Error
  2. Hello World : 11
  3. Hello World : 1
  4. Hello : 5
  5. Hello : 1

29. Suppose there is a file a.dat which has to be opened in the read mode using the FILE pointer ptr1, what will be the correct syntax?

Answers:

  1. ptr1 = open(“a.dat”);
  2. ptr1 = fileopen(“a.dat”);
  3. ptr1 = fopen(“a.dat”,”r”);
  4. ptr1 = open(“a.dat”,”r”);
  5. ptr1 = fileopen(“a.dat”,”r”);

30. Given the following array:

char books[][40]={
“The Little World of Don Camillo”,
“To Kill a Mockingbird”,
“My Family and Other Animals”,
“Birds, Beasts and Relatives”
};
what would be the output of printf(“%s”,books[3]);?

Answers:

  1. Birds
  2. B
  3. Birds, Beasts and Relatives
  4. My Family and Other Animals
  5. M

31. What would be printed on the standard output as a result of the following code snippet?

void main()
{
unsigned char a=25;
a = ~a;
signed char b = 25;
b = ~b;
printf(“%d %d “, a, b);
}

Answers:

  1. 0 0
  2. 230 230
  3. 230 -26
  4. 230 -103
  5. None of the above

32. Which function will convert a string into a double precision quantity?

Answers:

  1. atoi()
  2. atof()
  3. atol()
  4. atan()
  5. acos()

33. Which of the following is not a type of operator ?

Answers:

  1. Rational
  2. Unary
  3. Ternary
  4. Compound assignment
  5. Logical

34. The declaration int *(*p)[10] indicates:

Answers:

  1. p is an array of pointers to functions the return type of which is an integer
  2. p is a pointer to a function that returns a pointer to an integer
  3. p is a pointer to an array of integer pointers
  4. p is a pointer to a character string

35. What will be printed on the standard output as a result of the following code snippet?

void main()
{
int num1 = 30, num2 = 4;
float result;
result = (float)(num1/num2);
printf(“%.2f”, result);
return 0;
}

Answers:

  1. 7
  2. 7.00
  3. 7.000000
  4. 7.5
  5. 7.50

36. What is the output of the following program ?

main()
{

int u = 1, v = 3;
printf(“%d %d”,u,v);
funct1(&u,&v);
printf(” %d %dn”,u,v);
}

void funct1(int *pu, int *pv)
{
*pu=0;
*pv=0;
return;
}

Answers:

  1. 1 3 1 3
  2. 1 3 1 1
  3. 1 3 0 0
  4. 1 1 1 1
  5. 3 1 3 1

37. Which of the following is/are the correct signature/s of main with command line arguments?

Answers:

  1. int main(int argc, char **argv)
  2. int main(int argc, char *argv[])
  3. int main(int argc, char *argv)
  4. int main(int argc, char argv[])
  5. All of the above

38. From which of the following loop or conditional constructs, is “break” used for an early exit?

Answers:

  1. switch
  2. for
  3. while
  4. do-while
  5. All of the above

39. Given the operators:

1) *
2) /
3) %

What would be the order of precedence?

Answers:

  1. 1,2,3
  2. 1,3,2
  3. 3,2,1
  4. All have the same precedence
  5. 1 and 2 have the same precedence, 3 is of lower precedence

40. Which of the following declarations of structures is/are valid?

1)
struct node {
int count;
char *word;
struct node next;
}Node;
2)
struct node {
int count;
char *word;
struct node *next;
}Node;
3)
struct node {
int count;
char *word;
union u1 {
int n1;
float f1;
}U;

}Node;

Answers:

  1. 1,2,3
  2. 1,2
  3. 2,3
  4. 2
  5. None of the above

41. What would be printed on the standard output as a result of the following code snippet?

main( )
{
char *str[ ] = {
“Manish”
“Kumar”
“Choudhary”
};
printf ( “nstring1 = %s”, str[0] );
printf ( “nstring2 = %s”, str[1] );
printf ( “nstring3 = %s”, str[2] );
}

Answers:

  1. string1 = Manish string2 = Kumar string3 = Choudhary
  2. string1 = Manish string2 = Manish string3 = Manish
  3. string1 = ManishKumarChoudhary string2 = (null) string3 = (null)
  4. You will get an error message from the compiler

42. What would be printed on the standard output as a result of the following code snippet?

main()
{
int n=5, x;
x = n++;
printf(“%d “, x);
x = ++n;
printf(“%d “, x++);
printf(“%d”, x);
return 0;
}

Answers:

  1. 6 7 8
  2. 5 7 8
  3. 6 8 8
  4. 5 8 8
  5. None of the above

43. In which area of memory are static variables allocated?

Answers:

  1. stack
  2. heap
  3. With the code binary
  4. None of the above

44. Which standard function is used to deallocate memory allocated by the malloc() function?

Answers:

  1. free
  2. calloc
  3. delete
  4. release
  5. destroy

45. Read the statement below:

extern int a;

Which of the following statement/s pertaining to the above statement is/are correct?

Answers:

  1. Declares an integer variable a; Allocates storage for the variable
  2. Declares an integer variable a; Does not allocate the storage for the variable
  3. Indicates that the variable is defined outside the current file
  4. Brings the scope of the variable defined outside the file to this file
  5. All of the above
  6. None of the above

46. The declaration int (*p[5])() means:

Answers:

  1. p is an array of pointers to functions the return type of which is an integer
  2. p is a pointer to a function that returns a pointer to an integer
  3. p is a pointer to an array of integers
  4. p is a pointer to an array of integer pointers
  5. p is a pointer to a character string

47. What will be printed on the standard output as a result of the following code snippet?

void main()
{
int arr[5]={1,2,3,4,5};
printf(“%dn”, *(arr+4));
}

Answers:

  1. 1
  2. 2
  3. 4
  4. 5
  5. Cannot be determined

48. What would be printed on the standard output as a result of the following code snippet?

main()
{
char *pmessage = “asdfgh”;
*pmessage++;
printf(“%s”, pmessage);
return 0;
}

Answers:

  1. Will result in Compilation Error
  2. Undefined string
  3. sdfgh
  4. asdfgh

49. Which function returns the current pointer position within a file?

Answers:

  1. ftell()
  2. fseek()
  3. fgetc()
  4. fread()
  5. fscanf()

50. Which of the following is not a relational operator?

Answers:

  1. ==
  2. !=
  3. <>
  4. >=
  5. <=

51. What does the argv[0] represent?

Answers:

  1. The first command line parameter has been passed to the program
  2. The program name
  3. The number of command line arguments
  4. None of the above

52. What will happen when the following code is executed?

void main()
{
char arr1[] = “REGALINT”;
char arr2[10] = “REGALINT”;
printf(“%d,”,sizeof(arr1));
printf(“%d”,sizeof(arr2));
}

Answers:

  1. 1,1
  2. 1,4
  3. 8,8
  4. 8,9
  5. 9,10

53. What will be the output of the following program?

#include <assert.h>
main()
{
int n = 5;
assert(n > 3); //statement 1
n = n+2;
assert(n > 7);//statement 2
return 0;
}

Answers:

  1. Assertion ‘n > 3’ failed; Program aborts at statement 1
  2. Assertion ‘n > 7’ failed; Program aborts at statement 2
  3. Program returns 0 with the value of n as 7
  4. Compilation Error

54. Which of the following is a function for formatting data in memory?

Answers:

  1. sprintf()
  2. printf()
  3. scanf()
  4. free()
  5. atol()

55. Which function allocates memory and initializes elements to 0?

Answers:

  1. assign()
  2. calloc()
  3. malloc()
  4. swab()
  5. allocate()

56. Is the following statement correct? If not, why not? If yes, what is the size of the array?

int array[][3] = { {1,2}, {2,3}, {3,4,2} };

Answers:

  1. Yes, the size is three columns by two rows
  2. Yes, the size is two columns by two rows
  3. No, the first dimension is omitted
  4. No, one of the three initializer sets contains too many numbers
  5. Yes, the size is three columns by three rows

57. Which of the following sets of conversion statements may result in the loss of data?

Answers:

  1. int i; char c; i=c; c=i;
  2. int i; char c; c=i; i=c;
  3. int i; float f; i=f; f=i;
  4. None of the above

58. Consider the following code.

int i = 4, *j, *k;

Which one of the following statements will result in Compilation error?

Answers:

  1. j = &i;
  2. j = j + 4;
  3. j = j – 2;
  4. k = j + 3;
  5. j = j * 2;

59. What would be printed on the standard output as a result of the following code snippet?

main()
{
enum {red, green, blue = 0, white};
printf(“%d %d %d %d”, red, green, blue, white);
return 0;
}

Answers:

  1. Will result in Compilation Error
  2. 0 1 2 3
  3. 0 1 0 1
  4. 0 1 0 2
  5. Undefined

60. By which file function you can position the file pointer in accordance with the current position?

Answers:

  1. ftell()
  2. fseek()
  3. fgetc()
  4. fread()
  5. fscanf()

61. What is wrong with the following function prototype statement?

int func();

Answers:

  1. The function definition {…} is missing
  2. While calling a function, the type int is not needed
  3. No parameter has been passed
  4. The semicolon should not be there
  5. There is nothing wrong with the statement

62. What will be printed on the standard output as a result of the following code snippet?

void main()
{
char arr[] = {‘R’,’A’,’M’};
printf(“%d”,strlen(arr));
}

Answers:

  1. 0
  2. 1
  3. 3
  4. 4
  5. Cannot be determined

63. What will be printed on the standard output as a result of the following code snippet?

void main()
{
int arr[][2] = {1,2,3,4,5,6};
printf(“%d”,arr[2][1]);
}

Answers:

  1. 2
  2. 3
  3. 4
  4. 5
  5. 6

64. What would be printed on the standard output as a result of the following code snippet?

#include<stdio.h>
main()
{
unsigned char a=255;
a = a+1;
printf(“%d”,a);
return 0;
}

Answers:

  1. Undefined value
  2. 256
  3. 1
  4. 0
  5. -1

65. Which of the following is not a storage type?

Answers:

  1. auto
  2. global
  3. static
  4. register
  5. extern

66. If a two dimensional array arr[4][10](an array with 4 rows and 10 columns) is to be passed in a function, which of the following would be the valid parameters in the function definition?

Answers:

  1. fn(int arr[4][10])
  2. fn(int arr[][10])
  3. fn(int arr[4][])
  4. fn(int (*fn)[13])
  5. None of the above

67. Which function will you use to position the file pointer at the beginning of the file?

Answers:

  1. rewind()
  2. fseek()
  3. fscanf()
  4. a or b
  5. b or c

68. Which of the following is not a string function?

Answers:

  1. strlen()
  2. strcmp()
  3. strcpy()
  4. strcomp()

69. What would be printed on the standard output as a result of the following code snippet?

char i = ‘A’;
char *j;
j = & i;
*j = *j + 32;
printf(“%c”,i);

Answers:

  1. An error will occur
  2. a
  3. A
  4. b
  5. c

70. What will be printed on the standard output as a result of the following code snippet?

void main()
{
char arr1[] = “REGALINT”;
printf(“%d,”,strlen(arr1));
printf(“%d”,sizeof(arr1));
}

Answers:

  1. 1,1
  2. 8,4
  3. 8,8
  4. 8,9
  5. 9,8

71. What will be printed on the standard output as a result of the following code snippet?

int funr(int x, int y)
{
if(x <= 0)
{
return y;
}
else
{
return (1+funr(x-1,y));
}
}

void main()
{
printf(“%d”,funr(2,3));
}

Answers:

  1. 2
  2. 3
  3. 5
  4. 6
  5. 9

72. Which header file are methods(or macros) isalpha(), islower() a part of?

Answers:

  1. stdio.h
  2. ctype.h
  3. string.h
  4. math.h
  5. None of the above

73. What would be printed on the standard output as a result of the following code snippet?

#define Name Manish
main()
{
printf(“My name””Name”);
}

Answers:

  1. My name Manish
  2. My nameName
  3. Results in Compilation Error
  4. None of the above

74. What will be printed on the standard output as a result of the following code snippet?

void main()
{
int i,j,k;
i=4;
j=30;
k=0;
k=j++/i++;
++k;
printf(“%d %d %d”,i,j,k);
}

Answers:

  1. 5 31 8
  2. 5 31 7
  3. 5 31 6
  4. 4 30 7

75. What will be printed on the standard output as a result of the following code snippet?

main()
{
int num = 425;
printf(“%d”, printf(“%d”, num));
}

Answers:

  1. Will result in Compilation Error
  2. 4425
  3. 4253
  4. 3435
  5. None of the above

76. What would be printed on the standard output as a result of the following code snippet?

main()

{

signed char i = 1;

for (; i<=255; i++)

printf (“%d “,i);

return 0;

}

Answers:

  1. Compilation Error
  2. 1 2 3 … 255
  3. 1 2 3 . . . 127
  4. 1 2 3 . . . 127 -128 -127 … 0 1 2 3 . . . (infinite times)

77. What would be printed on the standard output as a result of the following code snippet?

#define max(a, b) ((a) > (b)?(a):(b))
main()
{
int a=4;
float b=4.5;
printf(“%.2fn”,max(a, b));
}

Answers:

  1. Results in Compilation Error
  2. Undefined value
  3. 4.50
  4. 4.0
  5. None of the above

78. Which of the following is not a file related function?

Answers:

  1. fgetc()
  2. puts()
  3. fputc()
  4. fscanf()
  5. fprintf()

79. What would be printed on the standard output as a result of the following code snippet?

main()
{
enum {red, green, blue = 6, white};
printf(“%d %d %d %d”, red, green, blue, white);
return 0;
}

Answers:

  1. 0 1 6 2
  2. 0 1 6 7
  3. Will result in Compilation Error
  4. None of the above

80. What would be printed on the standard output as a result of the following code snippet?

main()
{
int a[5] = {1,4,5,6,9};
printf(“%dt”, *a); //Line 1
printf(“%d”, *++a); //Line 2
return 0;
}

Answers:

  1. 1 4
  2. 0 1
  3. Undefined value
  4. Compilation Error in “Line 1”
  5. Compilation Error in “Line 2”

81. What would be printed on the standard output as a result of the following code snippet?

#define max(a, b)((a) > (b)?(a):(b))
main()
{
int a=4, c = 5;
printf(“%d “, max(a++, c++));
printf(“%d %dn”, a,c);
}

Answers:

  1. Results in Compilation Error
  2. 6 4 5
  3. 6 5 7
  4. 6 5 6
  5. None of the above

82. Which of the following file modes would mean read + append?

Answers:

  1. w+
  2. a+
  3. r+
  4. r+a
  5. a+r

83. Which of the following standard functions is used to close a file?

Answers:

  1. fileclose()
  2. closefile()
  3. fclose()
  4. Any of the above

84. What would be printed on the standard output as a result of the following code snippet?

int Recur(int num)
{
if(num==1 || num==0)
return 1;
if(num%2==0)
return Recur(num/2)+2;
else
return Recur(num-1)+3;
}

int main()
{
int a=9;
printf(“%dn”, Recur(a));
return 0;
}

Answers:

  1. 10
  2. 9
  3. 11
  4. 8
  5. None of the above

85. Identify the incorrect statement.

Answers:

  1. Records can be defined in C by using structures
  2. Structure members can be of the same/different data types
  3. Memory is reserved when a structure label is defined
  4. A pointer to a structure can be used to pass a structure to a function
  5. Arrays of structures can be defined and initialized

86. What will happen when the following code is executed?

{
int num;
num =0;
do {– num;
printf(“%dn”, num);
num++;
} while (num >=0);
}

Answers:

  1. The loop will run infinitely
  2. The program will not enter the loop
  3. There will be a compilation error
  4. A runtime error will be reported

87. Which of the following functions is used to extract formatted input from a file?

Answers:

  1. fputc()
  2. fputs()
  3. fprintf()
  4. fscanf()
  5. ftell()

88. What does the following function do?

int fn(unsigned int x)
{
int count = 0;
for(; x!=0; x&=(x-1))
count++;
return count;
}

Answers:

  1. Returns the minimum number of bits required to represent the number x
  2. Returns the number of zero bits present in the number x
  3. Returns the number of 1 bits(bits having one) in the number x
  4. Returns the square root of the number
  5. None of the above

1,168 total views, 6 views today

Upwork General Programming

Objective-C Test 2016

Published by:

1. What comments are supported in Obj-C?

Answers:

  1. // Line comments
  2. /* Block comments */
  3. # Line comments
  4. ; Line comments
  5. -[[ block comments ]]

2. What is a protocol?

Answers:

  1. A class that uses functions instead of methods
  2. A method signature
  3. A class signature
  4. An interface without an implementation
  5. None of the above

3. What is the isa variable in objects?

Answers:

  1. Object size
  2. Object memory footprint
  3. Object class identification
  4. Object serial numbe
  5. None of the above

4. In which version of Objective-C did the fast enumeration system appear?

Answers:

  1. 2.0
  2. 1.5
  3. 1.0
  4. 3.0

5. What is an IMP?

Answers:

  1. A special type used for computation
  2. An alias for SEL
  3. A preprocessor directive defined to the implementation name
  4. The C type of a method implementation pointe
  5. None of the above

6. What is the default visibility for instance variables?

Answers:

  1. @private
  2. @package
  3. @public
  4. @protected
  5. None of the above

7. What type of variable do you need to use to implement singletons?

Answers:

  1. static
  2. auto
  3. const
  4. volatile

8. What is a category?

Answers:

  1. A namespace
  2. A category is a way to add instance variables to a class which already exists
  3. A category is a group of classes
  4. A category is a way to add methods to a class which already exists
  5. None of the above

9. How do you allocate an object?

Answers:

  1. MyClass *obj = malloc(sizeof(MyClass));
  2. MyClass *obj = [MyClass alloc];
  3. MyClass *obj = alloc(MyClass);
  4. MyClass *obj = [MyClass new];
  5. None of the above

10. Is the following code a correct allocation?

MyClass myObj;

[&myObj aMessage];

Answers:

  1. Yes
  2. No

11. What is an autoreleased object?

Answers:

  1. A C object.
  2. A static object.
  3. An object that is garbage collected.
  4. An object that will be released when the current AutoreleasePool is deallocated.
  5. None of the above

12. Which of the following declares a protocol?

Answers:

  1. @proto ProtocolName
  2. protocol ProtocolName {};
  3. @protocol ProtocolName
  4. @interface <ProtocolName>
  5. @interface ProtocolName::Protocol

13. In which version of Objective-C did the properties system appear?

Answers:

  1. 3.0
  2. 2.5
  3. 2.0
  4. 1.5
  5. 1.0

14. What is the id type?

Answers:

  1. A generic C type that Objective-C uses for an arbitrary object
  2. A memory address type
  3. A type to hold serialized objects
  4. The type used for Classes
  5. None of the above

15. When using the garbage collector, which method, that is normally called without the collector, is not called on your objects where they are collected?

Answers:

  1. free
  2. dealloc
  3. destroy
  4. uninit

16. Which of the following creates a class that conforms to a protocol?

Answers:

  1. @interface ClassName [ProtocolName]
  2. @interface ClassName <ProtocolName>
  3. @interface ClassName < ProtocolName
  4. @interface ClassName::ProtocolName
  5. @interface ClassName(ProtocolName)

17. What is a @finally block?

Answers:

  1. A block that is executed when the program quits
  2. A block that is executed within a dynamic library when it’s unloaded
  3. A block of code that is run whenever an exception is thrown or not
  4. None of the above

18. What is true regarding @protected?

Answers:

  1. The instance variable is accessible within the class that declares it and within classes that inherit it
  2. The instance variable is accessible everywhere
  3. The instance variable is accessible only within the class that declares it.
  4. This is analogous to private_extern for variables and functions. Any code outside the class implementation’s image that tries to use the instance variable will get a link error
  5. None of the above

19. A class can conform to only one protocol.

Answers:

  1. True
  2. False

20. What class specifiers are supported?

Answers:

  1. FINAL
  2. STATIC
  3. FAST
  4. ITERATIVE
  5. There is no such thing as class specifiers

21. How do you throw an exception?

Answers:

  1. Raise Exception
  2. @throw exception
  3. RAISE exception
  4. THROW exception
  5. None of the above

22. What is nil?

Answers:

  1. The null object
  2. The null class
  3. It doesn’t exist
  4. None of the above

23. What does the following imply?

Worker *ceo = [[Worker alloc] init];
ceo->boss = nil;

Answers:

  1. That the ceo object is statically typed
  2. That the boss instance variable is declared @protected
  3. That the boss instance variable is declared @public
  4. That the ceo is in fact a structure
  5. This code is not correct

24. Can an exception caught in @catch be re-thrown?

Answers:

  1. Yes
  2. No

25. What is true regarding @public?

Answers:

  1. It doesn’t exist in Objective-C
  2. It breaks encapsulation
  3. It can be used only on singleton objects
  4. None of the above

26. Which of the following is false?

Answers:

  1. Method lookup is done at runtime
  2. When a method is called, the send is automatically available as the sender variable, like self or supe
  3. Messages can be sent to nil
  4. Methods in static libraries must be present at link time

27. What can you use to avoid the msgSend function overhead?

Answers:

  1. SEL
  2. IMP
  3. You can’t use anything
  4. None of the above

28. What does Obj-C not support?

Answers:

  1. Instance variables
  2. Class variables
  3. Static variables
  4. Automatic variables

29. What is not supported in Obj-C?

Answers:

  1. Recursive method call
  2. Variable argument count to method
  3. Byte manipulation
  4. Method argument default value
  5. None of the above

30. What will be the output of the following code?

static int

a (void)

{

printf (“an”);

return 0;

}
static int

b (void)

{

printf (“bn”);

return 1;

}
static int

c (void)

{

printf (“cn”);

return 2;

}
int

main (int argc, const char *argv[])

{

printf (“%d %d %d”, a (), b (), c ());

return 0;

}

Answers:

  1. a b c 0 1 2
  2. a b c 2 1 0
  3. c b a 0 1 2
  4. c b a 2 1 0
  5. None of the above

2,236 total views, 1 views today

Upwork General Programming

Objective C Test 2016

Published by:

1. What’s the difference between copy and deepCopy?

Answers:

  1. They are the same
  2. deepCopy doesn’t exist
  3. copy creates a copy at the first level, while deepCopy copies the instance variables
  4. copy creates a proxy object, while deepCopy allocate a new object
  5. None of the above

2. Which of the following can be inherited?

Answers:

  1. Categories
  2. Protocols
  3. Classes
  4. None of the above

3. Which of the following is the fastest?

Answers:

  1. @synchronized
  2. Explicit locking
  3. Condition locking
  4. Mutex implicit locking

4. A method can be tagged to be called only by a specific class and its subclasses.

Answers:

  1. True
  2. False

5. Which of the following is not recommended?

Answers:

  1. Adding an (id)sender argument to methods
  2. Using static variables inside methods
  3. Using C code inside Obj-C methods
  4. None of the above

6. A class can have two methods with the same name, but with different argument types.

Answers:

  1. True
  2. False

7. What are @try and @catch?

Answers:

  1. Exception handlers
  2. Exceptions
  3. Exception keywords
  4. All of the above

8. A class can conform to only one protocol.

Answers:

  1. True
  2. False

9. How do you free an object?

Answers:

  1. free(obj)
  2. [obj dealloc]
  3. [obj release]
  4. [obj free]
  5. None of the above

10. Which of the following creates a class that conforms to a protocol?

Answers:

  1. @interface ClassName [ProtocolName]
  2. @interface ClassName <ProtocolName>
  3. @interface ClassName < ProtocolName
  4. @interface ClassName::ProtocolName
  5. @interface ClassName(ProtocolName)

11. What is the isa variable in objects?

Answers:

  1. Object size
  2. Object memory footprint
  3. Object class identification
  4. Object serial number
  5. None of the above

12. What is true regarding C functions inside .m files?

Answers:

  1. They can contain Obj-C code
  2. They are slower than if in a .c files
  3. They cannot use C libraries
  4. They can be static

13. What is the id type?

Answers:

  1. A generic C type that Objective-C uses for an arbitrary object
  2. A memory address type
  3. A type to hold serialized objects
  4. The type used for Classes
  5. None of the above

14. What is a @finally block?

Answers:

  1. A block that is executed when the program quits
  2. A block that is executed within a dynamic library when it’s unloaded
  3. A block of code that is run whenever an exception is thrown or not
  4. None of the above

15. Is the following code a correct allocation?

MyClass myObj;
[&myObj aMessage];

Answers:

  1. Yes
  2. No

16. What does the following imply?

Worker *ceo = [[Worker alloc] init];
ceo->boss = nil;

Answers:

  1. That the ceo object is statically typed
  2. That the boss instance variable is declared @protected
  3. That the boss instance variable is declared @public
  4. That the ceo is in fact a structure
  5. This code is not correct

17. What is not supported in Obj-C?

Answers:

  1. Recursive method call
  2. Variable argument count to method
  3. Byte manipulation
  4. Method argument default value
  5. None of the above

18. Which of the following does not happen when you throw an exception in a @synchronized block?

Answers:

  1. The object is deallocated
  2. The object is unlocked
  3. An exception is thrown
  4. None of the above

19. Can you send messages to nil?

Answers:

  1. Yes
  2. No

20. In which version of Objective-C did the fast enumeration system appear?

Answers:

  1. 2.0
  2. 1.5
  3. 1.0
  4. 3.0

21. What can be linked to an Obj-C program without any particular process?

Answers:

  1. C libraries
  2. Java jar files
  3. C++ libraries
  4. scripts
  5. Executables

22. What is the C type used to work with objects in Obj-C?

Answers:

  1. int
  2. structure
  3. pointer
  4. array

23. What is a category?

Answers:

  1. A namespace
  2. A category is a way to add instance variables to a class which already exists
  3. A category is a group of classes
  4. A category is a way to add methods to a class which already exists
  5. None of the above

24. Protocols are like classes; they can inherit.

Answers:

  1. True
  2. False

25. What comments are supported in Obj-C?

Answers:

  1. // Line comments
  2. /* Block comments */
  3. # Line comments
  4. ; Line comments
  5. -[[ block comments ]]

26. Which of the following is false?

Answers:

  1. Method lookup is done at runtime
  2. When a method is called, the send is automatically available as the sender variable, like self or super
  3. Messages can be sent to nil
  4. Methods in static libraries must be present at link time

27. What happens if two categories define methods with the same names for the same class?

Answers:

  1. The code won’t compile
  2. At runtime, either method will be called
  3. A runtime exception will be thrown
  4. None of the above

28. What type of variable do you need to use to implement singletons?

Answers:

  1. static
  2. auto
  3. const
  4. volatile

29. As categories can’t have instance variables, what class could you use to implement a full class only with categories?

Answers:

  1. NSArray
  2. NSMutableDictionary
  3. NSSet
  4. None of the above

30. What can you do with categories?

Answers:

  1. Add instance variables to a class without subclassing it
  2. Add methods to a class without subclassing it
  3. Override methods of a class without subclassing it
  4. None of the above

31. How do you throw an exception?

Answers:

  1. raise Exception
  2. @throw exception
  3. RAISE exception
  4. THROW exception
  5. None of the above

32. What is true regarding strings?

Answers:

  1. C string literals are automatically mapped to objects
  2. C string literals can be used in Obj-C
  3. Obj-C strings are not of static storage<m/span>
  4. Obj-C strings are like C strings

33. In which version of Objective-C did the properties system appear?

Answers:

  1. 3.0
  2. 2.5
  3. 2.0
  4. 1.5
  5. 1.0

34. How do you include the root “Object” class?

Answers:

  1. #include <Object.h>
  2. #include <objc/Object.h>
  3. #include <Object/Object.h>
  4. #include <ROOT.h>
  5. It depends on the compiler

35. What is the default visibility for instance variables?

Answers:

  1. @private
  2. @package
  3. @public
  4. @protected
  5. None of the above

36. What is true regarding @protected?

Answers:

  1. The instance variable is accessible within the class that declares it and within classes that inherit it
  2. The instance variable is accessible everywhere
  3. The instance variable is accessible only within the class that declares it.
  4. This is analogous to private_extern for variables and functions. Any code outside the class implementation’s image that tries to use the instance variable will get a link error
  5. None of the above

37. What happens if you release an unretained object twice?

Answers:

  1. Nothing, too many releases are handled correctly
  2. Undefined behaviour
  3. MemoryException is raised
  4. None of the above

38. What is a protocol?

Answers:

  1. A class that uses functions instead of methods
  2. A method signature
  3. A class signature
  4. An interface without an implementation
  5. None of the above

39. In Obj-C 2.0, what do the fast enumeration protocols rely on to provide fast Enumerations?

Answers:

  1. C arrays
  2. Java Vectors
  3. Ruby hash
  4. Obj-C Array
  5. None of the above

40. Which of the following is incorrect?

Answers:

  1. [self release]
  2. [super release]
  3. [AClass release]
  4. They are all correct

41. What can you use to avoid the msgSend function overhead?

Answers:

  1. SEL
  2. IMP
  3. You can’t use anything
  4. None of the above

42. How do you allocate an object?

Answers:

  1. MyClass *obj = malloc(sizeof(MyClass));
  2. MyClass *obj = [MyClass alloc];
  3. MyClass *obj = alloc(MyClass);
  4. MyClass *obj = [MyClass new];
  5. None of the above

43. Which C feature is not supported in Obj-C?

Answers:

  1. Bitfields
  2. Compound literals
  3. Structures
  4. C arrays
  5. Support is compiler dependant

44. What does Obj-C not support?

Answers:

  1. Instance variables
  2. Class variables
  3. Static variables
  4. Automatic variables

45. What will be the output of the following code?

static int
a (void)
{
printf (“an”);
return 0;
}

static int
b (void)
{
printf (“bn”);
return 1;
}

static int
c (void)
{
printf (“cn”);
return 2;
}

int
main (int argc, const char *argv[])
{
printf (“%d %d %d”, a (), b (), c ());
return 0;
}

Answers:

  1. a b c 0 1 2
  2. a b c 2 1 0
  3. c b a 0 1 2
  4. c b a 2 1 0
  5. None of the above

46. When using the garbage collector, which method, that is normally called without the collector, is not called on your objects where they are collected?

Answers:

  1. free
  2. dealloc
  3. destroy
  4. uninit

47. What is nil?

Answers:

  1. The null object
  2. The null class
  3. It doesn’t exist
  4. None of the above

48. What can be used as Object instance variables?

Answers:

  1. int
  2. structures
  3. pointers
  4. unions
  5. None of the above

49. Can an exception caught in @catch be re-thrown?

Answers:

  1. Yes
  2. No

50. What is a SEL?

Answers:

  1. A selection
  2. The C type of a message selector
  3. The C type of a class
  4. A pointer to a method
  5. None of the above

51. What is an IMP?

Answers:

  1. A special type used for computation
  2. An alias for SEL
  3. A preprocessor directive defined to the implementation name
  4. The C type of a method implementation pointer
  5. None of the above

52. What is true regarding @public?

Answers:

  1. It doesn’t exist in Objective-C
  2. It breaks encapsulation
  3. It can be used only on singleton objects
  4. None of the above

53. What class specifiers are supported?

Answers:

  1. FINAL
  2. STATIC
  3. FAST
  4. ITERATIVE
  5. There is no such thing as class specifiers

54. Which of the following declares a protocol?

Answers:

  1. @proto ProtocolName
  2. protocol ProtocolName {};
  3. @protocol ProtocolName
  4. @interface <ProtocolName>
  5. @interface ProtocolName::Protocol

55. What is an autoreleased object?

Answers:

  1. A C object.
  2. A static object.
  3. An object that is garbage collected.
  4. An object that will be released when the current AutoreleasePool is deallocated.
  5. None of the above

56. If you need to allocate custom memory, in which method will you do so?

Answers:

  1. + alloc
  2. – alloc
  3. + init
  4. – init
  5. None of the above

57. What is #import

Answers:

  1. A namespace import rule
  2. A namespace definition
  3. A recursive include
  4. C preprocessor construct to avoid multiple inclusions of the same file
  5. None of the above

58. What is the Obj-C runtime?

Answers:

  1. A C library
  2. A compiler
  3. A language
  4. A dynamic loader

59. What is true regarding messaging?

Answers:

  1. Messaging is static and messages are replaced by function call at compile time
  2. Messaging is fully dynamic, which means you can compile some code that sends a message to a class that doesn’t implement it, and add a category later, in a dynamic library for example
  3. Messaging is only a syntax sugar to call functions
  4. None of the above is true

2,466 total views, 2 views today

Upwork General Programming

iPhone Programming OS 2.1 Test 2016

Published by:

1. Which of the following languages can be used to write the code for Xcode projects?

Answers:

  1. C
  2. C++
  3. Objective-C
  4. Objective-C++
  5. Java

2. Which of the following need to be modified while localizing an application?

Answers:

  1. Nib files (windows, views, menus).
  2. Static text.
  3. Icons and graphics.
  4. Dynamic text generated by your program.

3. Which of the following directives are used to declare and define classes, categories, and protocols?

Answers:

  1. @interface
  2. @implementation
  3. @protocol
  4. @class
  5. @end

4. Which of the following statements regarding Objective-C are correct?

Answers:

  1. In Objective-C, the keyword for NULL is nil.
  2. In Objective-C, #import and #include compiler directives carry out the same operations.
  3. In Objective-C, for the object-oriented constructs (such as method return values), id is the default data type.
  4. The keyword nil has an id with a value of 0.

5. Which of the following are valid touch attributes in a UITouch class object?

Answers:

  1. locationInView
  2. timestamp
  3. phase
  4. tapCount

6. Which of the following statements comply with the fundamental rules of Memory Management in Objective-C?

Answers:

  1. The ownership of the object is taken when it is created using a method the name of which begins with alloc or new or contains copy.
  2. The ownership of the objects is relinquished by using release or autorelease
  3. All other objects can also be released from memory using the release function.
  4. autorelease just means – send a release message later

7. The genstrings tool can parse _____.

Answers:

  1. C files with .c filename extension.
  2. Objective-C files with .m filename extension.
  3. Java code files with .java filename extension.
  4. Nib files with any file name extension.

8. Which of the following are the Derivative types defined in Objective-C?

Answers:

  1. short
  2. long
  3. long long
  4. int

9. Which of the following options regarding UIWindow and UIView classes are correct?

Answers:

  1. A UIWindow class object holds the contents of a UIView class object.
  2. A UIWindow class object can hold multiple sub-objects whereas a UIView class object can hold only one sub-object.
  3. Both UIWindow and UIView classes are required to display anything on the iPhone.
  4. UIWindow is the iPhone’s base window class and the UIView class is primarily an abstract super-class.

10. Which of the following statements regarding Memory Management are correct?

Answers:

  1. The alloc method creates a new object and returns it with a reference count of 1
  2. retain does not change the receiver’s reference count
  3. release decreases the receiver’s reference count by 1
  4. autorelease decreases the receiver’s reference count by 1 at some point in the future
  5. copy makes a copy of an object and increases the reference count by 1

11. Which of the following events occur when the retain count of the object drops to 0?

Answers:

  1. The release method is fired to relinquish the ownership of the object.
  2. The object is deallocated.
  3. The dealloc method is invoked automatically
  4. The resources associated with it are disposed

12. Which of the following SDK classes can be used to get the location of the movement of a finger on the iPhone screen?

Answers:

  1. UINavigationController
  2. UIEvent
  3. UITouch
  4. UIView

13. You have added the following code lines in your @implementation block in your ControllerView file:

@synthesize textField;
@synthesize label;
@synthesize string;

And in your dealloc method, you have added the following code lines:

– (void)dealloc {
[textField release];
[label release];
[string release];
[super dealloc];
}

What is the purpose of adding the above lines in your dealloc method?

Answers:

  1. To release the instance variables
  2. To conform to the rules of memory management
  3. To make the variables available for reuse in application
  4. To terminate the program

14. Which of the following terms are related to Memory Management in Objective-C?

Answers:

  1. alloc
  2. mutableCopy
  3. delete
  4. release

15. In your iPhone application, you want to apply an action sheet style that will display white text with transparent black background whenever a confirmation is required from the user. You have a UIActionSheet class object named “actionuser”. Which of the following code snippets is the right one for applying this style?

Answers:

  1. [ actionuser setActionSheetStyle: 0 ];
  2. [ actionuser setActionSheetStyle: 1 ];
  3. [ actionuser setActionSheetStyle: 2 ];
  4. [ actionuser setActionSheetStyle: 3 ];

16. Is NSMutableArray thread safe?

Answers:

  1. Yes
  2. No

17. What is the purpose of active executable in an Xcode project?

Answers:

  1. To specify which program is launched and how, when you run or debug from within Xcode.
  2. To select the appropriate configuration of the active target and each target it depends upon while building.
  3. To define different build configurations for different circumstances such as development or release.
  4. To build products for Multiple Platforms.

18. Which of the following samples returns the first name of a person listed under p in the address book?

Answers:

  1. ABPersonGetValue(p, kABFirstNameProperty);
  2. ABPersonCopyValue(p, kABFirstNameProperty);
  3. ABRecordGetValue(p, kABPersonFirstNameProperty);
  4. ABRecordCopyValue(p, kABPersonFirstNameProperty);
  5. [p firstName];

19. In which file is the following function called in your application?

int retVal = UIApplicationMain(argc, argv, nil, nil);

Answers:

  1. info.plist
  2. Any file with .m extension
  3. main.m only
  4. Any file with .h extension
  5. ControllerView file
  6. Nib file

20. State whether the following statement is true or false:

Interface Builder doesn’t generate source code

Answers:

  1. True
  2. False

21. Can you place calls using the iPhone SDK?

Answers:

  1. Yes
  2. No

22. Can you use POSIX threads on the iPhone?

Answers:

  1. Yes
  2. No

23. Which of the following is the correct syntax for declaring a class in Objective-C?

Answers:

  1. @interface ClassName : ItsSuperclass { instance variable declarations } method declarations @end
  2. @implementation ClassName : ItsSuperclass { instance variable declarations } method declarations @end
  3. @class ClassName : ItsSuperclass { instance variable declarations } method declarations @end
  4. All are correct

24. Locking all connections before editing the Nib files can be achieved by using:

Answers:

  1. An option in the Start Menu.
  2. An option in the Preferences panel of Interface Builder.
  3. An option in the Preferences panel of Language Directory.
  4. Any of the above.

25. What is the endianness of the network for IP communications?

Answers:

  1. Big endian
  2. Little endian
  3. Mixed endian
  4. Swapped endian
  5. Single endian

26. What is the screen resolution of the iPhone 3G?

Answers:

  1. 720×540
  2. 480×320
  3. 320×240
  4. 540×280
  5. 540×480

27. Which of the following methods does the UIKit provide in order to draw a string at a specific point.

Answers:

  1. NSString
  2. drawAtPoint:
  3. drawAsPatternInRect
  4. All of the above

28. From which of the following classes does a UITextView class object inherit its features?

Answers:

  1. UIScroller
  2. UIView
  3. UIControl
  4. UITextField

29. Which of the following can be used to draw a tiled image?

Answers:

  1. Quartz 2D function CGContextDrawTiledImage
  2. UIViews
  3. Either a or b
  4. Neither a not b

30. In your iPhone application, you want that the user should be able to select the date in Month, Day and Year mode. You have a UIDatePicker class object named dateModePicker. Which of the following code snippets is correct in order to apply this mode?

Answers:

  1. [ dateModePicker setDatePickerMode: 0 ];
  2. [ dateModePicker setDatePickerMode: 1 ];
  3. [ dateModePicker setDatePickerMode: 2 ];
  4. [ dateModePicker setDatePickerMode: 3 ];

31. Which of the following is the base class for all iPhone applications?

Answers:

  1. UIActionSheet
  2. UIApplication
  3. UIControl
  4. UIApplicationDelegate

32. In the CALayer class, the property contentsGravity allows you to position and scale the layer’s contents image within the layer bounds. What is the role of the kCAGravityLeft positioning constant in contentsGravity?

Answers:

  1. It positions the content image in the top left corner of the layer.
  2. It positions the content image vertically centered on the left edge of the layer.
  3. It positions the content image in the bottom left corner of the layer.
  4. It positions the content image at the center of the layer.

33. Before editing the Nibs, one should:

Answers:

  1. Unlock all connections.
  2. Lock all connections.
  3. Break all connections.
  4. None of the above

34. Given the string “192.168.1.1”, how can you get an integer address (to fill a sockaddr_in structure)?

Answers:

  1. With inet_ntoa
  2. With inet_aton
  3. With NSString
  4. All addresses are in ASCII format
  5. None of the above

35. Can you use POSIX sockets on the iPhone?

Answers:

  1. Yes
  2. No

36. If you want to know if a host is reachable via the network, what would you use in your application?

Answers:

  1. ping
  2. NSURL isReachable: method
  3. NSNetwork discover: method
  4. SCNetworkReachabilityCreateWithName
  5. None of the above

37. What happens if Xcode is not able to find a file or folder at the path defined for it in the project?

Answers:

  1. Xcode skips the file or the folder and continues execution.
  2. Xcode gives an alert with a description of the missing file.
  3. Xcode displays the item in red in the project window.

38. In which language is the address book framework written?

Answers:

  1. Objective-C
  2. C
  3. C++
  4. Ruby
  5. Java

39. When the genstrings tool discovers a key string used more than once in a single strings file, it:

Answers:

  1. deletes the comments from the individual entries and leaves one comment string without generating a warning.
  2. merges the comments from the individual entries into one comment string and generates a warning.
  3. differentiates the comments from the individual entries into various strings and generates a warning.
  4. None of the above

40. Which of the following classes is used to internalize an XML into a logical tree structure?

Answers:

  1. NSData class
  2. NSXMLDocument class
  3. NSXMLNode class
  4. NSPropertyListSerialization class

41. What is the CompressResources build step in an iPhone Xcode project?

Answers:

  1. It resizes all the files in the project for displaying them in the iPhone.
  2. It resizes the png files in the project for displaying them in the iPhone.
  3. It compresses the files with the extensions .m and .h.
  4. It changes the extension of the files and compresses them.

42. Can CGGradientRef be used on the iPhone to draw gradients?

Answers:

  1. Yes
  2. No

43. While using an iPhone, a user switches from one application to another application or service on the device. What is the most important factor to be kept in mind to ensure that your application reflects the most recent changes made by the user the next time it starts?

Answers:

  1. The user should be asked to click save and close from the start menu
  2. The user should be asked to close your application
  3. The application should be programmed to save any user changes as they are made as quickly as possible.
  4. No specific consideration in this regard is necessary

44. Which of the following debugging environments are provided by Xcode to find and squash bugs in your code?

Answers:

  1. Debugging from the text editor
  2. Mini Debugger
  3. Debugger window
  4. GDB debugger console
  5. All of the above

45. On the iPhone, what are the types of Person entries and Group entries?

Answers:

  1. ABPersonRef and ABGroupRef
  2. ABPerson and ABGroup
  3. ABRecordRef and ABRecordRef
  4. ABRecord and ABRecord
  5. None of the above

46. How do you play a short sound on the iPhone?

Answers:

  1. With the NSSound class
  2. With the UISound class
  3. With AudioServicesPlaySystemSound function
  4. With NSSystemSound function
  5. None of the above

47. What is the function of the Code Sense feature in Xcode?

Answers:

  1. Code Sense helps in switching between different circumstances such as development or release.
  2. Code Sense maintains an index that contains important information for your project.
  3. Code Sense creates a cache for the files which are being used frequently.
  4. Code Sense maintains an index of files used in a project.

48. Whenever the iPhone users switch to another application like answering the phone, or checking their email, the application they were previously using _____.

Answers:

  1. quits
  2. keeps running
  3. resumes as soon as the other application is terminated
  4. may or may not resume depending on the application

49. Does ABPersonCreate function add the newly created record into the address book?

Answers:

  1. Yes
  2. No

50. How can you prevent a view from receiving touch events?

Answers:

  1. By overriding UIResponder relevant methods
  2. By setting userInteractionEnabled to false
  3. By setting shouldDeliverEvent to false
  4. You can’t
  5. None of the above

51. Which of the following is true?

Answers:

  1. An application thread can have only one NSAutoreleasePool
  2. NSAutoreleasePool is thread safe
  3. NSAutoreleasePool should not be used outside the main thread
  4. Each thread maintains its own stack of NSAutoreleasePool objects
  5. None is true

52. Refer to the given image:

Which of the above window panes will display Build system output when Xcode builds your target and shows the corresponding warnings and errors?

Answers:

  1. A
  2. B
  3. C
  4. None of the above

53. Which of the following classes automatically manages transition
animation between Views?

Answers:

  1. UIAnimationController
  2. UIViewAnimation
  3. CGViewAnimation
  4. UIApplicationDelegate
  5. UINavigationController

54. Which of the following is not a touch event method?

Answers:

  1. – (void)touchesDragged:(NSSet *)touches withEvent:(UIEvent *)event;
  2. – (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
  3. – (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
  4. – (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
  5. – (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event

55. How many windows does an iPhone application typically have?

Answers:

  1. 0
  2. 1
  3. 2
  4. 10
  5. None of the above

56. Which of the following shapes is generated by Views in an iPhone?

Answers:

  1. Rectangular
  2. Square
  3. Rhombus
  4. All of the above

57. How can you restrict the delivery of multi-touch events to their subviews

Answers:

  1. You can’t
  2. By manually redirecting events from the event handlers
  3. By overriding hitTest:withEvent:
  4. By registering the subview in the notification center
  5. None of the above

58. Using the following function, what will you get from the default database?

NSUserDefaults* defs = [NSUserDefaults standardUserDefaults];
NSArray* languages = [defs objectForKey:@”AppleLanguages”];
NSString* preferredLang = [languages objectAtIndex:0];

Answers:

  1. The list of preferred languages.
  2. The user’s preferred language.
  3. The user’s default language.
  4. The list of languages supported by the application.

59. Which of the following should be used to draw 3D content?

Answers:

  1. OpenGL
  2. OpenGL ES
  3. Direct 3D
  4. None of the above

60. Which of the following is a feature of CAPropertyAnimation class in Core Animation?

Answers:

  1. It is an abstract subclass that provides support for animating a layer property specified by a key path
  2. It allows an array of animation objects to be grouped together and run concurrently
  3. It provides simple interpolation for a layer property
  4. It provides a transition effect that affects the entire layer’s content. It fades, pushes, or reveals layer content when animating

61. While recording a sound, how can you know if the source of the sound is from the built-in microphone or headphone microphone?

Answers:

  1. With the NSSound class method named audioSource
  2. With the AudioQueueGetParameters function
  3. By querying the registry
  4. By polling for audio events
  5. iPhone OS 2.1 version does not support sound recording.

62. Can non-main threads poll for events?

Answers:

  1. Yes
  2. No

63. What can trigger a call to touchesCancelled:withEvent: ?

Answers:

  1. The user lifting all fingers from the phone
  2. A system event, such as a phone call
  3. The user lifting one or more fingers from the phone
  4. This method doesn’t exist
  5. None of the above

64. In which of the following classes are the addChild, insertChild, and removeChildAtIndex methods defined?

Answers:

  1. NSXMLElement Class
  2. NSXMLNode Class
  3. NSXMLDocument class
  4. NSPropertyListSerialization class

65. While opening Nib files, which of the following should not be ignored?

Answers:

  1. Objects in a Nib file typically have connections between them that should not be broken.
  2. If Objects in a Nib file have broken connections, they should not be restored.
  3. The size of the files.
  4. None of the above

66. What does CFSocketGetNative return?

Answers:

  1. A CF opaque type
  2. A POSIX socket handle
  3. A native Cocoa object
  4. A binary representation of the socket incoming data in machine native endian
  5. None of the above

67. Are instances of ABAddressBookRef thread safe?

Answers:

  1. Yes
  2. No

68. Which of the following best describes View Controllers?

Answers:

  1. View Controllers provide access to data.
  2. View Controllers implement Views’ inner logic.
  3. View Controllers regulate Views’ animations.
  4. View Controllers provide the basic user interface logic for presenting numerous application views to the user.
  5. None of the above

69. Is NSRunLoop thread safe?

Answers:

  1. Yes
  2. No

70. What is the default value for the anchorPoint property in Layer Geometry?

Answers:

  1. (0.0,0.0)
  2. (0.0,0.5)
  3. (0.5,0.0)
  4. (0.5,0.5)
  5. (1.0,1.0)

71. Can the iPhone use Bonjour messaging?

Answers:

  1. Yes
  2. No

72. Which of the following debugging tasks are provided by Xcode to find and squash bugs in your code?

Answers:

  1. Add and set breakpoints.
  2. View your call stack per thread.
  3. View the value of variables by hovering the mouse pointer over them.
  4. Execute a single line of code.
  5. All of the above

73. If the code is written using the Core Foundation and Foundation macros, the simplest way to create strings files is:

Answers:

  1. Using an option in the Preferences panel of Interface Builder.
  2. By merging the comments from the individual entries into one comment string.
  3. By unlocking all connections.
  4. By using the genstrings command-line tool.

74. Which type of data is returned by the following function?

CFDataRef CreateDataFromImage(UIImage *image)

{
return CGDataProviderCopyData(CGImageGetDataProvider(image.CGImage));
}

Answers:

  1. Binary image data.
  2. Raw pixel data.
  3. Compressed image data.
  4. ASCII image data.

75. How can you play video on the iPhone from your application?

Answers:

  1. With QuickTime
  2. With OpenGL ES
  3. With the MediaPlayer framework
  4. With VideoCodecServices

76. If you try to run an application in the iPhone Simulator without having created the ControllerView Nib file, what will happen?

Answers:

  1. The application will crash
  2. The application will run smoothly
  3. If you set the Nib file name to nil using initWithNibName:nil, the application will run
  4. The application will take time to load

77. Which design pattern for your application periodically sends messages to another object to ask for input or to notify that an event is occurring?

Answers:

  1. Model-View-Controller
  2. Delegation
  3. Target-action

78. Choose the correct statement:

To “flip” your user interface:

Answers:

  1. use the standardViewTransition:forInterface:Cache: method of the UIView class, and provide the appropriate constant to specify the flip direction.
  2. use the setAnimationTransition:forView:Cache: method of the UIView class, and provide the appropriate constant to specify the flip direction.
  3. use the setUICatalog:forView:Cache: method of the UIView class reference, and provide the appropriate constant to specify the flip direction.
  4. The user interface can not be flipped

79. What is the default setting to refer to file locations in your Xcode project?

Answers:

  1. Relative to Build Product
  2. Relative to Project
  3. Relative to Enclosing Group
  4. Relative to <source path>
  5. Absolute Path

80. How can you create an OpenGL ES texture with a .png image?

Answers:

  1. Using UIImage glTexture property
  2. Using UIImageBitmapRep
  3. Using CGContextDrawImage in a CGBitmapContext
  4. You can’t
  5. None of the above

81. By which of the following methods can an NSAutoreleasePool object be created?

Answers:

  1. autorelease
  2. alloc
  3. copy
  4. retain

82. Is OpenAL available on the iPhone?

Answers:

  1. Yes
  2. No

83. What are universal binaries in Xcode?

Answers:

  1. These are executable files that can contain code and data for more than one architecture.
  2. These are file references which are generated by the target, such as an application.
  3. These are indexes that contain symbolic information for your project.
  4. These are used to specify build location settings.

84. The most effective way to ensure that users have a positive application-switching experience is to _______.

Answers:

  1. enhance the launch time of the application to the maximum
  2. reduce the memory space allocated to all applications
  3. pare the launch time of the application to the minimum
  4. disable any unused applications

85. Which of the following classes will be used to embbed web content in an iPhone application?

Answers:

  1. UIWebView
  2. UIViewController
  3. UINavigationController
  4. UITabBarController

86. Are multiple touches enabled by default?

Answers:

  1. Yes
  2. No

87. Can your application change the global sound volume?

Answers:

  1. Yes
  2. No

88. Which of the following statement is incorrect with regard to Object Ownership in Memory Management?

Answers:

  1. An object may have one or more owners
  2. An object is owned by the user if it is created using alloc
  3. If an object is copied, the retain count is returned as 0
  4. If an object has no owners, its retain count drops to 0

2,145 total views, 1 views today

Upwork General Programming

Game Programming Concepts Test 2016

Published by:

1. What is true regarding DirectX and OpenGL?

Answers:

  1. DirectX is a collection of API for games programming.
  2. DirectX is much faster than OpenGL.
  3. DirectX is more frequently used in professional graphics.
  4. OpenGL is an open standard.
  5. OpenGL is multi-platform.

2. Shadow volumes use per-pixel lighting.

Answers:

  1. True
  2. False

3. What does dereferencing mean in C?

Answers:

  1. Accessing a pointer’s value
  2. Accessing the value pointed by a pointer
  3. Adding a second reference to a pointer
  4. None of the above

4. What is the Gilbert-Johnson-Keerthi algorithm used for?

Answers:

  1. Collision detection
  2. Texture uploading
  3. File compression
  4. Network priority queue

5. What is a data structure?

Answers:

  1. A list of values with names associated to them
  2. An object array
  3. An event list
  4. None of the above

6. What are the differences between anisotropic filtering and trilinear filtering?

Answers:

  1. Anisotropic filtering gives a better quality than trilinear filtering
  2. Trilinear gives a better quality than Antisotropic filtering
  3. Anisotropic filtering performs a linear interpolation
  4. Trilinear filtering doesn’t take the angle of vision into account
  5. Trilinear filtering needs more bandwidth than anisotropic filtering

7. What is the result of a dot product?

Answers:

  1. A vector
  2. A scalar
  3. A matrix
  4. None of the above

8. A UDP client sends a packet to a server on port 80. The server responds using port 50’234 as source port. What will the result be?

Answers:

  1. It will always work.
  2. The response packet might be blocked by state-full firewalls.
  3. The server will crash when trying to use a different port.
  4. None of the above

9. In a networked game, the client can be coded in C while the server is coded in Ruby.

Answers:

  1. True
  2. False

10. How many 3 dimension vectors are needed to position and orient an object in space?

Answers:

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5

11. What is 3D audio?

Answers:

  1. 3D audio is a technique used to add sound to a 3D environment.
  2. 3D audio is a sound effect that creates the illusion of multiple sound sources placed anywhere in the 3D space.
  3. 3D audio is a special effect that makes sound like in a specific place.
  4. None of the above.

12. How much memory will an 8 bit per channel RGBA texture of 256×256 pixels take?

Answers:

  1. 2Mbytes
  2. 2Mbit
  3. 2Moctet
  4. 2Kbytes

13. What is a cross product?

Answers:

  1. The product of two floats
  2. The product of two vectors
  3. The product of two matrices
  4. The product of two ints
  5. None of the above

14. A texture is composed of fragments.

Answers:

  1. True
  2. False

15. What is a bones system?

Answers:

  1. A technique in modeling to animate a 3D model
  2. A skeleton used for the animation of a 3D model
  3. A skeletal animation
  4. A technique to create a 3D model

16. What does bump mapping do?

Answers:

  1. It flattens a texture
  2. It adds a relief effect to a texture
  3. It adds minor displacements to a surface
  4. None of the above.

17. What does the following statement describe?

It renders the scene from the light point of view, in a depth texture; then it renders the scene again from the camera point of view using the depth texture to determine if a pixel is in shadow or not.

Answers:

  1. Collision detection
  2. Depth mapping
  3. Shadow mapping
  4. Texture mapping
  5. None of the above

18. What are shadow volumes?

Answers:

  1. Shadow volumes are a technique used in 3D computer graphics to add shadows to a rendered scene.
  2. Shadow volumes are a fast way to add shadows to a 3D scene.
  3. Shadow volumes are a very slow way to add shadows to a 3D scene.
  4. None of the above.

19. What are pbuffers?

Answers:

  1. Point buffer objects
  2. Pixel buffer objects
  3. Particle buffer objects
  4. None of the above

20. The UDP is an acknowledged protocol.

Answers:

  1. True
  2. False

21. How many layers are there in the OSI model?

Answers:

  1. 1
  2. 3
  3. 5
  4. 7
  5. 9

22. The fundamental idea behind particles is that they are immune to physics laws (collisions, …).

Answers:

  1. True
  2. False

23. A particle engine can be done using either vertices or fragments.

Answers:

  1. True
  2. False

1,420 total views, 3 views today

Upwork General Programming

Dot Net Fundamentals Test 2016

Published by:

1. Which of the following are included in a Static assembly?

Answers:

  1. Modules
  2. Type metadata
  3. MSIL code
  4. Assembly manifest

2. Which of the following are the main goals behind ADO .NET?

Answers:

  1. To provide seamless support for XML
  2. To support COM directly
  3. To provide an expandable and scalable data access architecture for the revolutionary n-tier programming model
  4. To extend the current capabilities of ADO

3. Application domains are created by:

Answers:

  1. Windows shell
  2. ASP.Net
  3. IE
  4. None of the above

4. Which of the following are correct about delegates?

Answers:

  1. A delegate is an object that refers to a subroutine, function or other method
  2. A delegate variable acts as a pointer to a subroutine or function
  3. A delegate can not hold the address of a class’s shared method
  4. Delegate variables are sometimes called type-safe function pointers

5. Which of the following protocols can be used for .Net Remoting?

Answers:

  1. TCP
  2. HTTP
  3. SMTP
  4. All of the above

6. Which of the following is correct for value and reference types in .NET?

Answers:

  1. Value types directly contain their data
  2. Reference types store a reference to the value’s memory address
  3. Value types can be built-in but can’t be user-defined
  4. All of the above

7. Which of these are runtime hosts in .Net Framework?

Answers:

  1. CLR
  2. IE
  3. IIS
  4. ASP.NET

8. Which of the following run In-Process?

Answers:

  1. EXE file
  2. Resx file
  3. DLL file
  4. OCX file

9. A manifest includes the following data about the assembly

Answers:

  1. File list
  2. None
  3. Referenced assemblies
  4. MSIL information

10. The Process of automatic memory management involves the following tasks:

Answers:

  1. Allocating memory
  2. Registering memory
  3. Implementing finalizers
  4. Using destroy

11. A standard Windows PE file is divided into a number of sections. Which of the following are not valid native image sections?

Answers:

  1. .textdata
  2. .data
  3. .rpdata
  4. .rsrc

12. Which of the following statements is true?

Answers:

  1. You can access managed data from managed code
  2. You can access managed data from managed and unmanaged code
  3. Managed code can access both managed and unmanaged data
  4. Managed code cannot access both managed and unmanaged data

13. Which of the following methods are used to stop a thread?

Answers:

  1. Thread.Interrupt()
  2. Thread.Suspend()
  3. Thread.Sleep()
  4. Thread.Abort()

14. ___________ class grants the permission to manipulate files located in the code assemblies, to code assemblies that match the membership condition.

Answers:

  1. FileCodeGroup
  2. FirstMatchCodeGroup
  3. CodeFileGroup
  4. CodeGroup

15. Which of the following statements is correct with regard to .NET framework managed web pages?

Answers:

  1. They interact directly with the runtime
  2. They do not execute in the native code language
  3. They are interpreted and scripted
  4. All of the above

16. Which of the following protocols can be used for ASP.Net Web Services?

Answers:

  1. TCP
  2. HTTP
  3. SMTP
  4. All of the above

17. When are AssemblyHash values used?

Answers:

  1. They are used throughout the common language runtime to detect a change in assembly contents
  2. They are used in the Common type system for type safety
  3. They are used to change the metadata information in assemblies

18. In.NET generics, the type parameter:

Answers:

  1. Needs to be constrained in container classes
  2. Needs to be constrained in all the classes
  3. Cannot be constrained in container classes
  4. Cannot be constrained in any class

19. How many classes can a single .NET DLL contain?

Answers:

  1. 10
  2. 20
  3. Unlimited
  4. 5

20. Where is the Shared assembly generally stored?

Answers:

  1. Application’s directory
  2. Global assembly cache
  3. C drive
  4. None of the above

21. Which of the following is not correct with regard to shared assembly?

Answers:

  1. Its version can be controlled by the author only
  2. It can be shared by many applications
  3. It must get registered with the machine registry
  4. It is installed in the global assembly cache

22. Which Portable Executable (PE) file does not contain the assembly manifest?

Answers:

  1. Executable
  2. DLL
  3. Module
  4. ALL

23. In .NET framework, what are the options available for packaging?

Answers:

  1. CAB
  2. EXE
  3. MSI
  4. All of the above

24. Which of the following are public methods of System.Object?

Answers:

  1. GetHashCode()
  2. GetType()
  3. Equals()
  4. All of the above

25. Which of the following helps expose COM components to the .NET framework?

Answers:

  1. RCW
  2. CCA
  3. CWA
  4. CCW

26. Which of the following tools can be used to get the metadata information about the assembly and view IL code?

Answers:

  1. soapsuds.exe
  2. lldasm.exe
  3. al.exe
  4. PerfMon.exe
  5. SN.exe

27. Which of the following tools assists Assembly Signing?

Answers:

  1. CASPol.exe
  2. PerfMon.exe
  3. SN.exe
  4. soapsuds.exe

28. In which file can you define the “Process Model” attribute?

Answers:

  1. Web.config
  2. Machine.config
  3. In both files
  4. In neither file

29. C# has a keyword called int. Which .NET type does this map to?

Answers:

  1. System.Int16
  2. System.Int32
  3. System.Int64
  4. System.Int128

30. Which of the options is being referred to in the following statement:

“All incoming requests are processed by a single server object”

Answers:

  1. SingleCall
  2. Client-activated object
  3. Singleton
  4. None of these

31. A user application-domain can be created:

Answers:

  1. Automatically
  2. By using a static method “CreateAppDomain”
  3. By using a static method “CreateDomain”
  4. By using a non static method “CreateAppDomain”

32. The global assembly cache:

Answers:

  1. Can store two dll files with the same name
  2. Can store two dll files with the same name, but different version
  3. Can store two dll files with the same name and same version
  4. Can not store dll files with the same name

33. What does Managed Data refer to?

Answers:

  1. The data stored by CLR
  2. The data allocated by CLR GC
  3. The data de-allocated by CLR GC
  4. The data allocated and de-allocated by CLR GC

34. Which tool can you use to register managed types with the Windows registry?

Answers:

  1. SN.exe
  2. Regasm.exe
  3. lldasm.exe
  4. none

35. Which of the following files is used to implement application and session level events?

Answers:

  1. Global.asax
  2. Web.config
  3. Machine.config
  4. None of the above

36. Which of these classes are used for loading an assembly into an application domain?

Answers:

  1. System.Configuration.Assemblies
  2. system.componentModel
  3. System.Resources
  4. System.AppDomain

37. Which of the following tools can be used to modify and grant permissions to code groups?

Answers:

  1. Soapsuds.exe
  2. Lldasm.exe
  3. CASPol.exe
  4. PerfMon.exe
  5. SN.exe

38. Which of the following does not use metadata?

Answers:

  1. CLR
  2. CTS
  3. JIT compilers
  4. Class loader
  5. None of the above

39. Which of the following functionalities does System.Diagnostics class provide?

Answers:

  1. Reflection
  2. Trace
  3. Manage code
  4. Remoting

40. An application can have any number of modules and files. Which of the following is used to link them together into a single assembly?

Answers:

  1. al.exe
  2. ac.exe
  3. bl.exe
  4. ad.exe

41. What is the command “caspol -lg” used for?

Answers:

  1. To see the private assemblies
  2. To see the assemblies in GAC
  3. To see the code groups defined on your system
  4. To see the metadata information

42. Which of the following is a must for a private assembly?

Answers:

  1. Cryptographically strong name
  2. Unique name
  3. Cryptographically Light name
  4. Global assembly cache

43. Code Manager is a the part of:

Answers:

  1. CTS
  2. CLI
  3. CLS
  4. CLR

44. Why doesn’t .Net runtime offer deterministic destruction?

Answers:

  1. Due to CTS
  2. Due to Finalize class
  3. Due to garbage collection algorithm
  4. Due to the JIT

45. Consider the following two statements and choose the most appropriate option:

Statement 1: Value types are allocated on a stack
Statement 2: Reference types are allocated on a managed CLR Heap

Answers:

  1. Statement 1 is true and statement 2 is false
  2. Statement 2 is true and statement 1 is false
  3. Both statements 1 and 2 are true
  4. Both statements 1 and 2 are false

46. Which of the following is used to notify all waiting threads of a change in the object’s state?

Answers:

  1. The system.Threading.Monitor.ReferenceEquals method
  2. The system.Threading.Monitor.Enter method
  3. The system.Threading.Monitor.PulseAll method
  4. The system.Threading.Monitor.TryEnter method

47. Which of the following manages the code during execution?

Answers:

  1. Coding Manager
  2. JIT
  3. COde Manager
  4. Coder Manager

48. Which type of parameter is passed in subroutines by default?

Answers:

  1. ByRef
  2. ByVal

49. Which of the following is not a member of the Exception class?

Answers:

  1. StackTraceID
  2. Message
  3. InnerException
  4. TargetSite

50. Which transport protocol is used to call a Web Service?

Answers:

  1. SOAP
  2. HTTP
  3. SMTP
  4. ALL

51. How many application domains can exist inside a Win32 process?

Answers:

  1. 1
  2. 2
  3. Any number
  4. 4

52. Which of the following helps Assemblies become self describing?:

Answers:

  1. JIT
  2. Manifest
  3. CTS
  4. Application Domain

53. How will you use the thread pool?

Answers:

  1. By calling the ThreadPool.UserQueueWorkItem() method directly
  2. By passing an instance of WaitCallback delegate to the ThreadPool.QueueUserWorkItem() method
  3. By passing an instance of WaitCallback delegate to the ThreadPool.UserQueueWorkItem() method
  4. By passing an instance of StayCallback delegate to the ThreadPool.QueueUserWorkItem() method

54. The runtime is started automatically by ______________ when the .exe is run.

Answers:

  1. mscore.dll
  2. mscoree.dll
  3. mscor.dll
  4. mscoren.dll

55. Because .NET treats all languages as equal, a class written in C# should be equivalent to a class written in VB.NET, and an interface defined in Managed C++ should be exactly the same as one that is specified in Managed COBOL. Languages must agree on the meanings of these concepts before they can integrate with one another.

Which of the following provides the specifications for this?

Answers:

  1. CLS
  2. CTS
  3. MSIL
  4. CLI

56. .Net assembly stores both data and IL code. A tool is available along with the .NET framework to view within the PE. Which of the following is that tool?

Answers:

  1. ildasm.exe
  2. disasm.exe
  3. deassmbler.exe
  4. deasm.exe

57. Which of the following services are provided by CLR?

Answers:

  1. Application memory isolation
  2. Code Management
  3. Verification of type safety
  4. Conversion of IL to native code
  5. All of the above

58. Which of these files is used for debugging an application?

Answers:

  1. demo.dll
  2. demo.pdb
  3. demo.res
  4. Any of these can be used

59. Compilers of CLS compliant language generate:

Answers:

  1. MSIL code and Metadata
  2. MSIL code
  3. Metadata
  4. Machine code

60. Which of these is used to allow managed code to interoperate with unmanaged code?

Answers:

  1. COM
  2. COM Marshaler
  3. XML
  4. SOAP

61. Which of the following statements is correct.

(a)A Try block must include Catch or Finally sections.
(b)Using an empty Finally section is illegal.

Answers:

  1. Only (a) is true
  2. Only (b) is true
  3. Both (a) and (b) are false
  4. Both (a) and (b) are true

62. The _________________ methods are primarily meant for COM Interoperability use.

Answers:

  1. System.AppDomain.ApplyPolicy
  2. System.AppDomain.CreateComInstanceFrom
  3. System.AppDomain.Load
  4. System.AppDomain.GetAssemblies

63. How does CLR allow multiple applications to be run in a single process?

Answers:

  1. By running them in a special application domain
  2. By making sub process for each process
  3. By loading them in separate application domains
  4. None of the above

64. _____________ helped overcome the DLL conflict (faced by the versions prior to .NET).

Answers:

  1. Strong-named assemblies
  2. Version-aware code storage
  3. Components executing in isolation
  4. All of the above

65. __________ is used to generate the assembly from modules.

Answers:

  1. soapsuds.exe
  2. lldasm.exe
  3. al.exe
  4. PerfMon.exe
  5. SN.exe

66. Which of the following is used as a Serializer for the web services?

Answers:

  1. XmlSerializer
  2. SoapSerializer
  3. BinaryFormatter
  4. SoapFormatter

67. The IL to native code compilation is done by:

Answers:

  1. Code Manager
  2. CTS
  3. JIT
  4. CLS

68. ____ is a subset of the CTS.

Answers:

  1. CLI
  2. cLS
  3. CLR
  4. None of these

69. Which of the following is valid and is included in the type definition?

Answers:

  1. Any attribute that is defined in the type
  2. The name of the type
  3. The visibility of the type
  4. The base types of the type
  5. All of the above
  6. None of the above

70. Which of the following statements is correct?

Answers:

  1. For in-process communication between contexts within a single application domain, Serialization is used as an interception mechanism.
  2. For in-process communication between contexts within a single application domain, Marshaling is used as an interception mechanism.
  3. For in-process communication between contexts within a single application domain, Proxies are used as an interception mechanism.
  4. All of the above

71. Which of the following are used in combination to create the identity of an assembly?

Answers:

  1. Assembly name
  2. Version
  3. Culture
  4. Public key
  5. All of the above

72. Which of these Assemblies is used for doing Localization?

Answers:

  1. Private
  2. Public
  3. Satellite
  4. Both Public and Private

73. Which of the following is not a feature of .NET 2.0?

Answers:

  1. Partial classes
  2. Generics
  3. Multiple Inheritance
  4. Partial Methods

74. ___________ namespace is not defined in the base class library.

Answers:

  1. System
  2. System.CodeDom
  3. System.IO
  4. System.Threading
  5. System.Text

75. Since .NET assemblies contain IL code, your proprietary algorithms can be seen by anyone. Which of the following tools protects your intellectual properties?

Answers:

  1. Obfuscator
  2. Befprotector
  3. Obadministrator
  4. Befmanager

76. For MSIL code to be executed in PE file, it is necessary to have:

Answers:

  1. Assembly manifest
  2. Modules
  3. Files
  4. Types

77. __________ assembly can be used to deploy language-specific resources for an application.

Answers:

  1. Shared
  2. Private
  3. Satellite
  4. Public

78. Which of the following can you use to resolve assemblies, types, and resources?

Answers:

  1. System.AppDomain.CreateDomain
  2. System.AppDomainSetup.ApplicationBase
  3. System.AppDomainSetup.CreateComInstanceFrom
  4. System.AppDomain.ApplyPolicy

79. .NET components are accessed from COM via a?

Answers:

  1. RCW
  2. CCA
  3. CWA
  4. CCW

80. How will you prevent concurrent access to your data?

Answers:

  1. By using System.Threading.ThreadStart
  2. By using System.Threading.Monitor.Enter/Exit methods
  3. By using System.Threading.Monitor.start/End methods
  4. By using System.Threading.ThreadEnter

81. Which of the following is correct for CTS?

Answers:

  1. It establishes a framework that helps enable cross-language integration, type safety, and high performance code execution
  2. It provides an object-oriented model that supports the complete implementation of many programming languages
  3. It defines rules that languages must follow, which helps ensure that objects written in different languages can interact with each other
  4. All of the above

82. Delay signing allows a shared assembly to be signed with:

Answers:

  1. Private key at the initial stage
  2. Private and Public key at the initial stage
  3. Private key at a later stage
  4. Public key at a later stage

83. What happens when enough memory is not available to be allocated to an object?

Answers:

  1. MemoryFull exception is thrown
  2. Garbage collector is automatically run to free up memory
  3. OutOfMemory exception is thrown
  4. The .Net worker process is restarted

84. You can create the remote application domain using:

Answers:

  1. AppDomain.BuldDomain
  2. AppDomain.MakeDomain
  3. AppDomain.CreateDomain
  4. AppDomain.GenerateDomain

85. Which base class do all web forms inherit from?

Answers:

  1. System.Web.UI.Page
  2. System.Web.UI.HtmlControls
  3. System.Web.UI.WebControls
  4. None of the above

86. Where is the application domain created?

Answers:

  1. Outside a Process
  2. Inside a Process
  3. Can be created in both the places
  4. None of the above

87. Microsoft .NET supports value types for performance reasons, but everything in .NET is ultimately an object. Value types are allocated on the stack by default, but they can always be converted into a heap-based, reference-type object.
What is this conversion called?

Answers:

  1. Conving
  2. Boxing
  3. TypeModification
  4. None of the above

88. A hashtable is serialized by using:

Answers:

  1. XmlSerializer or SoapFormatter
  2. XmlSerializer
  3. SoapFormatter
  4. XmlSerializer and SoapFormatter

89. The .NET framework comes with a few CLR hosts. Which of the following is a CLR host?

Answers:

  1. ASP.NET
  2. IE
  3. Shell Executables
  4. All of the above

90. Which of the following code is not ‘managed’ by default in .NET framework?

Answers:

  1. Visual Basic
  2. C#
  3. C++
  4. Jscript

91. .NET provides a distributed process framework. Which of the following technologies are used for similar function?

Answers:

  1. Java Remote Method Invocation
  2. Microsoft Distributed Component Object Model
  3. Common Object Request Broker Architecture
  4. Remote Procedure Calls

92. Which of the following is used to do garbage collection?

Answers:

  1. gc.Collect
  2. gc.KeepAlive
  3. gc.SuppressFinalize

93. How many bits does the int datatype use in .NET?

Answers:

  1. 16 bits
  2. 32 bits
  3. 64 bits
  4. None of the above

94. Which of the following tools can be used to configure assemblies located in the GAC?

Answers:

  1. Soapsuds.exe
  2. Lldasm.exe
  3. CASPol.exe
  4. Mscorcfg.msc
  5. SN.exe

95. You assigned the version number – 5.3.1.0 to your assembly.

The four digits stand for:

Answers:

  1. Revision, Built, Major Version, and Minor version
  2. Revision, Built, Minor Version, and Major version
  3. Built, Major version, Minor Version, and Revision
  4. Major version, Minor Version, Built, and Revision

96. Which of the following is not correct about parameter arrays?

Answers:

  1. A subroutine can have any numbers of parameter arrays
  2. A parameter array must come last in the parameter list
  3. All parameter lists are declared as ByVal
  4. Parameter array values are implicitly optional

97. Which of the following is incorrect about Structures?

Answers:

  1. Structures are value types
  2. A structure can provide a constructor
  3. Structures can implement inheritance
  4. Structures support events

98. Which of the following is not a valid inheritance_mode?

Answers:

  1. Overloads
  2. Overrides
  3. Overridable
  4. MustOverridable
  5. None of the above

99. In .NET framework, Reflection is used to:

Answers:

  1. Create metadata of the modules/assemblies
  2. Get metadata of the modules/assemblies
  3. Reengineer the corrupted assemblies
  4. Destroy the corrupted assemblies

100. Xcopy method is not sufficient for deployment:

Answers:

  1. When application relies on shared assemblies
  2. When application is downloaded on demand
  3. When the number of assemblies is too large
  4. None of the above

101. Dot Net Framework consists of :

Answers:

  1. Common language runtime
  2. Set of class libraries
  3. Common language runtime and set of class libraries
  4. Common language runtime, set of class Libraries, and ADO.NET

102. Which of the following statements is not correct with regard to .NET assemblies?

Answers:

  1. Static assemblies can include classes, JPEG files, resource files etc.
  2. Static assemblies are stored on disk in PE files.
  3. The .NET Framework can create dynamic assemblies
  4. Dynamic assemblies are automatically saved to disk before execution

103. Which of the following statements is correct with regard to Windows process memory allocation?

Answers:

  1. Each process (instance of an application) gets its own RAM and prevents the OS from crashing when the process crashes
  2. RAM is shared between the processes and saves OS crash with the process crash
  3. Each process gets its own RAM and causes OS to crash with the process crash
  4. RAM is shared between the processes and causes OS to crash with the process crash

104. The code written to target common language runtime services is called :

Answers:

  1. Generated Code
  2. Managed Code
  3. Unmanaged Code
  4. CLR Code
  5. Service Code

105. Which of the following should you use to serialize instances of a class?

Answers:

  1. XMlSerializer
  2. It depends on the situtaion
  3. SoapFormatter
  4. BinaryFormatter

106. What are the core components of .NET framework data provider model?

Answers:

  1. DataAdapter and DataReader
  2. Connection and Command
  3. DataAdapter, Connection, and Command
  4. DataAdapter , DataReader, Connection, and Command

107. Which of the following can not be used with files?

Answers:

  1. FileClose
  2. FileInput
  3. LineInput
  4. LOF
  5. PrintLine

108. ____________ class defines the set of information that constitutes input to security policy decisions in System.Security.Policy namespace.

Answers:

  1. FileCodeGroup
  2. ApplicationTrust
  3. Evidence
  4. PolicyLevel
  5. PolicyStatement

1,195 total views, 1 views today