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 databases
  1. LENGTH

  2. CONCAT

  3. INSTR

  4. NULLIF

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

CONCAT can return non-NULL when passed NULL because it concatenates non-NULL values and ignores NULL arguments. For example, CONCAT('abc', NULL) returns 'abc'. LENGTH(NULL) returns NULL. INSTR with NULL returns NULL. NULLIF returns NULL if its arguments are equal, otherwise the first argument.

Multiple choice technology web technology
  1. byte

  2. String

  3. integer

  4. Float

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

In Java, primitive types are the basic data types built into the language: byte, short, int, long, float, double, char, boolean. String is a class (reference type). integer is not a valid Java type (it should be int). Float is a wrapper class, not a primitive (float is the primitive).

Multiple choice technology web technology
  1. byte

  2. String

  3. integer

  4. Float

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

In Java, primitive types are the basic data types built into the language: byte, short, int, long, float, double, char, and boolean. Among the options, only 'byte' is a primitive type. 'String' is a class, 'integer' is not a valid keyword (the primitive is 'int'), and 'Float' is a wrapper class (the primitive is 'float').

Multiple choice technology programming languages
  1. for

  2. break

  3. continue

  4. Structure

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

Java keywords are reserved words with specific meanings in the language. 'for', 'break', and 'continue' are built-in control flow keywords. 'Structure' is not a keyword in Java (unlike 'struct' in C/C++). Note that Java keywords are case-sensitive and lowercase.

Multiple choice technology web 2.0
  1. false

  2. true

  3. both

  4. none

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

When using the POST method, form variables are sent in the HTTP request body, not displayed in the URL. This provides better security and privacy for sensitive data compared to GET method, which appends variables to the URL. The answer is 'false' because POST does NOT display variables in the URL - that's the defining characteristic of POST vs GET.

Multiple choice technology databases
  1. GADDE

  2. Gadde

  3. gADDE

  4. THERE IS NO FUNCTION LIKE initcap();

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

The Oracle SQL function INITCAP() converts the first letter of each word to uppercase and all remaining letters to lowercase. When applied to 'gadde', it returns 'Gadde' with only the first letter capitalized. This function is commonly used for formatting names and titles in database queries.

Multiple choice technology databases
  1. GADDE

  2. Gadde

  3. gADDE

  4. THERE IS NO FUNCTION LIKE initcap();

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

This is a duplicate of question 142268. The Oracle SQL function INITCAP() converts the first letter of each word to uppercase and all remaining letters to lowercase. When applied to 'gadde', it returns 'Gadde' with only the first letter capitalized.

Multiple choice technology programming languages
  1. x contains an int value

  2. x contains an object of the Circle type.

  3. x contains a reference to a Circle object.

  4. You can assign an int value to x.

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

To understand this question, the user needs to have basic knowledge of object-oriented programming and class declaration. In the given declaration Circle x = new Circle(), we are creating an object of the Circle class.

Now let's go through each option to determine the correct answer:

A. x contains an int value: This statement is incorrect because the Circle class does not contain int values. Therefore, x cannot contain an int value.

B. x contains an object of the Circle type: This statement is correct. The code is creating an object of the Circle class and assigning it to the variable x. Therefore, x contains an object of the Circle type.

C. x contains a reference to a Circle object: This statement is correct. In Java, objects are created on the heap and accessed through references. When we create an object of a class, we are creating an instance of that class on the heap and assigning a reference to that instance to a variable.

D. You can assign an int value to x: This statement is incorrect because x is declared as an object of the Circle class, not as an int. Therefore, you cannot assign an int value to x.

The correct answer is: C. x contains a reference to a Circle object.

Multiple choice technology programming languages
  1. true, 1, Null

  2. false, 0, null

  3. true, 0, null

  4. true, 1, null

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

In Java, boolean fields default to false, numeric types (int, double, etc.) default to 0, and object types default to null. This is consistent across all primitive and reference types. Options A, C, and D incorrectly use 'true' or '1' for boolean or numeric defaults.

Multiple choice technology programming languages
  1. Char i = 9

  2. int i = 3/7

  3. String i = "abc"

  4. int i = 0

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

In Java, adding a string to another string (i + 0) performs string concatenation (e.g., "abc" + 0 yields "abc0"). Since "abc" is not equal to "abc0", i != i + 0 evaluates to true, and it loops indefinitely. For numeric types, adding 0 does not change the value, so the loop terminates immediately.

Multiple choice technology web technology
  1. Single line c++ syntax - //

  2. Shell syntax - #

  3. Both of above

  4. None of above

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

PHP supports both C++ style single-line comments (//) and shell style comments (#). This flexibility allows developers to choose their preferred commenting style or use both in the same codebase for different purposes.