Search This Blog

Sunday, April 13, 2025

Can I use a C Macro in a Java program?

Can I use a C Macro in a java program?

The answer is YES, you can.

Java programming does not use macros, but you can use C macros in Java. To do that you can pipe the source code containing macro and Java code through the C preprocessor. Below is an example code:


Now, before you compile the Java code, pipe it to the C preprocessor:

cpp -P MacroTest.java macros/MacroTest.java

Note: Make sure all the folders are created properly before the source code is submitted to the C preprocessor.

Next, go to the macros directory to view the Java code generated by CPP.


Compile and run this source code as usual :



Follow my blog for more @ https://kannancy.blogspot.com/








Monday, April 7, 2025

Java - this keyword - 1

 In Java, this keyword can be used in more than one way. Does the program below accurately use this keyword?

What happens when you run this code?


a) Compile time error - invalid use of this at line 18

b) Runtime error - invalid nested call to a constructor

c) Program prints - hello

d) Program prints - hi


Type your answer in the comment.


Follow and share my blog for more interesting posts on programming and DS.



C Preprocessor - 1

A macro or a preprocessor statement is used by the compiler before it compiles the program to transform the program.

What is the output of the following C program?



a) Compile-time error at line 3

b) Compile-time error at line 6 

c)  Hello world!

d) Runtime error - print expected

Friday, April 4, 2025

functions and pointers Program 1

 What will happen when you run this program?




   a) Compile time error: mismatch of data type of function argument in line 7
   b) Prints garbage
   c) Prints 11 and 21
   d) Prints 11 and 22

Type your answer in a comment.



printf and scanf functions

 In which of the following header files printf and scanf functions are included?

a) inout.h

b) stdlib.h

c) stdio.h

d) io.h


Provide your answer in a comment.

Thursday, April 3, 2025

Can you guess which of these is a keyword of C Programming Language?

 Which of the following is a keyword of C Programming language?

a) printf

b) scanf

c) sizeof

d) getstr


Type the answer in a comment

Wednesday, April 2, 2025

Datatype int in C

 What is the size of an int (integer) in the C language?

a) 1 byte

b) 2 bytes

c) 4 bytes

d) depending on OS