Computer Knowledge

Programming Fundamentals

2,381 Questions

Programming fundamentals form the core logic of software development and computer science. This includes variable declarations, pointer assignments, loop iterations, and exception handling. These technical topics are regularly tested in computer knowledge and IT officer competitive examinations.

Variables and arraysPointer assignmentsLoop iterationsException handling blocksCompile time errorsFunction references

Programming Fundamentals Questions

Multiple choice technology programming languages
  1. char *gcvt(double value,int digit,char buf);

  2. char *gcvt(double value,int digit,char *buf);

  3. char *gcvt(double value,int digit,char *buf)

  4. char *gcvt(double value,int digit,char buf)

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The standard C function gcvt converts a double-precision floating-point number to a string and stores it in a buffer. Its prototype requires a character pointer char *buf to store the string, and a semicolon at the end of the declaration.

Multiple choice technology web technology
  1. rake db:migrations

  2. rake db:migrate

  3. rake db:migrates

  4. rake db:migrate project

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The correct Rails command is 'rake db:migrate' - this applies pending migrations to the database. Options A and C use incorrect verb forms ('migrations' and 'migrates' instead of 'migrate'), and D incorrectly adds 'project' as an argument. The Rails migration syntax follows the pattern 'rake db:taskname'.

Multiple choice technology web technology
  1. database.xml

  2. database.rb

  3. database.yml

  4. db_config.xml

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Rails uses YAML format for configuration files, and database settings are stored in config/database.yml. This file contains connection details for different environments (development, test, production). The .yml extension is standard for YAML files, not .xml or .rb.

Multiple choice technology security
  1. Trace, warn, error and fatal

  2. Trace, debug, info, warn, error and fatal

  3. Debug, info, error, fatal

  4. Debug, Warn, Error

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The security API provides four logging levels: Trace (most detailed), Warn (warning conditions), Error (error events), and Fatal (critical failures). This level progression allows developers to control log verbosity and focus on issues of varying severity. The option with six levels is incorrect - debug and info are not part of this API's logging hierarchy.

Multiple choice technology mainframe
  1. never

  2. if A is equal to B

  3. if A is different from B

  4. always

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

In COBOL, the period (.) terminates the scope of the IF-THEN-ELSE statement. Since instruction-3 follows the period ending the ELSE clause, it is outside the conditional logic. Consequently, instruction-3 is executed unconditionally, meaning it will always run regardless of whether variable A is equal to B or not.

Multiple choice technology
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

When objects are dragged from the Library and dropped into other objects or the main design area, Dialogue automatically creates a reference to that object rather than copying it. This reference-based approach allows changes to the original library object to propagate to all instances where it's used, maintaining consistency across the design.

Multiple choice technology mainframe
  1. Infinite loop

  2. logical error

  3. runtime error

  4. All of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

All three error types are possible within a COBOL IF statement: infinite loops (if logic never terminates), logical errors (incorrect condition logic), and runtime errors (invalid data access during condition evaluation). Therefore 'All of the above' is correct.

Multiple choice technology mainframe
  1. in-line PERFORMS

  2. EVALUATE

  3. IF

  4. all

Reveal answer Fill a bubble to check yourself
A,B Correct answer
Explanation

Scope terminators (like END-PERFORM, END-EVALUATE) are mandatory for in-line PERFORMs and EVALUATE statements to clearly delimit the statement block. They are optional (not mandatory) for IF statements, though recommended for clarity. 'all' is incorrect.

Multiple choice technology web technology
  1. SQL Injection

  2. Out of Memory exception

  3. Session Management and Tracking

  4. SQL Tracing

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

SQL Injection is a well-known web application security risk where attackers manipulate database queries through malicious input. It can allow unauthorized data access, modification, or deletion. The other options listed (Out of Memory, Session Management, SQL Tracing) are primarily operational issues or internal concerns rather than external security vulnerabilities that attackers exploit.

Multiple choice technology web technology
  1. a. It misses catch block and gives compile time error

  2. b. It misses catch block and give run time excpetion

  3. c. Code above compiles successfully

  4. d. Placement of finally block is not proper

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Java allows try-finally blocks without a catch clause - this is valid syntax. The finally block executes regardless of whether an exception occurs, making it useful for resource cleanup. A catch block is only required if you want to handle specific exceptions.