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
  1. This method returns the closest long or int, as indicated by the method's return type, to the argument.

  2. This method returns the smallest integer that is greater than or equal to the argument as a double.

  3. This method returns the largest integer that is less than or equal to the argument as a double.

  4. This method returns a String object representing the value of specified int or Integer.

  5. This method converts the primitive data type of a certain String.

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

ceil() method does this.

Multiple choice
  1. str

  2. st

  3. struct

  4. stt

  5. structure

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

A struct in C programming language is a structured (record) type that aggregates a fixed set of labelled objects, possibly of different types, into a single object.

Multiple choice
  1. string.h

  2. stdio.h

  3. conio.h

  4. stdlib.h

  5. math.h

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

Input and Output operations can also be performed in C using the C Standard Input and Output Library (cstdio, known as stdio.h in the C language). This library uses what are called streams to operate with physical devices such as keyboards, printers, terminals or with any other type of files supported by the system.

Multiple choice
  1. toLower()

  2. trim()

  3. split()

  4. both 1 and 3

  5. both 2 and 3

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

This is the correct answer. Because there is no method defined in the String class named toLower(). So it cannot be invoked using the object of String class.The correct method is toLowerCase() which converts the characters to lowercase.So this is correct answer according to the question asked.

Multiple choice
    • 1
  1. 11

  2. 6

  3. Compiler error : method lastIndexOf() not declared

  4. Compiler error : parameters to method not sufficient

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

lastIndexOf(String s , index i) method return the last occurrence of string s before the from index. Return -1 if string not found. So here the string to find is “Java” before the index 5 which means before the character m.but string “java” is not present before the index 5 i.e character m.so it will return -1.So this is the correct answer.

Multiple choice
  1. 16

  2. 4

  3. 18

  4. 3

  5. 15

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

The correct answer is 16. When stringbuffer object is created the default capacity of the object is always 16.If the number of characters in the string increases the capacity will increase with the following formula:-2 * (previous capacity + 1)In this case hello has 5 characters so default capacity will not change.So this is correct answer.

Multiple choice
  1. replace(char , char)

  2. replaceAll(String , String)

  3. append(String)

  4. both 1 and 2

  5. all of these

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

This is the correct answer. Because the String class objects are immutable i.e once the object of the String class is created its contents cannot be changed.So we cannot append new characters or string in the old string.So this is the correct answer.