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. for(int i=10;i>0;i-=-2);

  2. for(int i=0;i<012;i=i++);

  3. for(int i=0;i<0;i--);

  4. for(int i=0;(i++^--i)==0;i++);

  5. for(int i=010;i==10;i+=0);

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

Option B is infinite because i=i++ uses post-increment incorrectly - i is assigned its old value each time, so i stays 0 forever. Option D is infinite because the XOR (i++ ^ --i) compares a number with itself after increment/decrement cancel out, and any number XOR itself equals 0, making the condition always true. Option A terminates (i decreases from 10 to 2 in 5 steps). Option C never runs (condition false initially). Option E never runs (010 is octal 8, not 10).

Multiple choice technology programming languages
  1. A

  2. B

  3. C

  4. D

  5. E

  6. F

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

To run a packaged Java class, you must specify its fully qualified name. Running from /apps with the default classpath requires java com.company.application.MainClass. Alternatively, you can specify the classpath explicitly using -classpath /apps from any directory.

Multiple choice technology programming languages
  1. BeginPaint()

  2. OnFrame()

  3. OnCreate()

  4. CreateFrame()

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

OnCreate() is the method that gives physical presence to a frame in MFC applications. It's called when the frame is being created and is where you should perform initialization that requires the window to exist. BeginPaint() is for painting, OnFrame() and CreateFrame() are not standard MFC methods.

Multiple choice technology programming languages
  1. LPVOID

  2. LPCSTR

  3. BOOL

  4. LRESULT

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

LRESULT is the data type used for return values from window procedures in Win32 API. It's designed to handle the various return values needed by window procedures, including handles, boolean values, and other status codes. LPVOID, LPCSTR, and BOOL are not appropriate return types for window procedures.