Programming Languages Quiz: C, Java, and RPG
Test your knowledge across multiple programming languages including C, Java, and RPG (IBM AS/400). Covers file I/O, memory allocation, operators, interfaces, inheritance, and system-specific operations.
Questions
Find the output of this program. main() { int i=5; printf(“%d”,i=++i ==6); }
- 6
- 1
- 5
- Compiler error
Question 3 Given: 11. public class Test { 12. public static void main(String [] args) { 13. int x =5; 14. boolean b1 = true; 15. boolean b2 = false; 16. 17.if((x==4) && !b2) 18. System.out.print(”l “); 19. System.out.print(”2 “); 20. if ((b2 = true) && b1) 21. System.out.print(”3 “); 22. } 23. } What is the result?
- D. 2 3
- A. 2 B. 3
- C. 1 2 E. 1 2 3
- F. Compilation fails. G. Au exceptional is thrown at runtime.
- public interface Status { 12. /* insert code here */ int MY_VALUE = 10; 13. } Which three are valid on line 12? (Choose three.)
- A. final
- C. native
- F. abstract
- G. protected
Question 5 Given: 10. interface Foo {} 11. class Alpha implements Foo { } 12. class Beta extends Alpha {} 13. class Delta extends Beta { 14. public static void main( String[] args) { 15. Beta x = new Beta(); 16. // insert code here 17. } 18. } Which code, inserted at line 16, will cause a java.lang.ClassCastException?
- B. Foo f= (Delta)x;
- A. Alpha a = x;
- D. The code on line 31 throws an exception.
- C. Foo f= (Alpha)x; D. Beta b = (Beta)(Alpha)x;
Question 3 Given: 11. public class Test { 12. public static void main(String [] args) { 13. int x =5; 14. boolean b1 = true; 15. boolean b2 = false; 16. 17.if((x==4) && !b2) 18. System.out.print(”l “); 19. System.out.print(”2 “); 20. if ((b2 = true) && b1) 21. System.out.print(”3 “); 22. } 23. } What is the result?
- D. 2 3
- A. 2 B. 3
- C. 1 2 E. 1 2 3
- F. Compilation fails. G. Au exceptional is thrown at runtime.
- public interface Status { 12. /* insert code here */ int MY_VALUE = 10; 13. } Which three are valid on line 12? (Choose three.)
- A. final
- C. native
- F. abstract
- G. protected
Question 5Given:10. interface Foo {}11. class Alpha implements Foo { }12. class Beta extends Alpha {}13. class Delta extends Beta {14. public static void main( String[] args) {15. Beta x = new Beta();16. // insert code here17. }18. }Which code, inserted at line 16, will cause ajava.lang.ClassCastException?
- B. Foo f= (Delta)x;
- A. Alpha a = x;
- D. The code on line 31 throws an exception.
- C. Foo f= (Alpha)x; D. Beta b = (Beta)(Alpha)x;
Find the output of this program. main() { int a[10]; printf("%d",*a+1-*a+3) ; }
- Compiler error
- 3
- -2
- 4
Find the output of this program. main() { int i=5; printf(“%d”,i=++i ==6); }
- 6
- 1
- 5
- Compiler error
Find the output of this program. main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }
- -1
- 1
- 0
- Compiler error
Find the output of this program. void main(){ float j; j=1000*1000; printf("%f",j); }
- 1000000
- Overflow
- None
- Error
Which of the following is used to allocate memory to a program at run time?
- ALLOCATE
- ALLOC
- ALLMEM
- LOADM
- None of the above
Which of the following is the operation code extender for not locking a record on a READ or CHAIN?
- L
- N
- E
- P
- none of the above
Given a full procedural, externally-described input file named ORDER with a record length of 41 bytes, which of the following is a valid format for the File specification for the ORDER file?
- A. FORDER IF E DISK
- B. FORDER IPE F 41 DISK
- C. FORDER IF E 41 DISK
- D. FORDER IF F DISK
Given a full procedural, externally-described input file named ORDER with a record length of 41 bytes, which of the following is a valid format for the File specification for the ORDER file?
- A. FORDER IF E DISK
- B. FORDER IPE F 41 DISK
- C. FORDER IF E 41 DISK
- D. FORDER IF F DISK
What type of object stores spooled files that are waiting to be printed on an output device?
- *SPLQ
- *PRTQ
- *PRTF
- *OUTQ
Given the following code, what is the value of RESULT? DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++ D RESULT S 5 0 CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++++++++++++++++ C EVAL RESULT = (2 + 3 * 2) * 2 / 2
- 8
- 10
- 32
- 50
If the last record of a file has been read, and the next operation on that file is a READ operation, what will be the values of the input fields for that file?
- They will be blank and/or zero.
- They will be null.
- They will equal the values of the first record in the file.
- They will equal the values of the last record read
Given the DOS Specification below and the following information: • Indicator 50 is off • No records have been written to the subfile What will be the result if the EXFMT operation code is performed on the record format CTLR? A R SUBFL A DESCRIP 101 6 1ODSPATR(UL) A DFT(’NOT FOUND’) A R CTLR SFLCTL(SUBFL) A N50 SFLDSP A SFLDSPCTL A SFLINZ A 67 SFIJEND A SFLSIZ(13) A SFLPAG(12) A ACCOUNTNO 100 S 10
- Only AccountNo will display
- SUBFL will be initialized with 13 blank records
- An I/O exception error will occur
- The screen will display 12 records with ‘NOT FOUND’
Given the DOS Specification below and the following information: • Indicator 50 is off • No records have been written to the subfile What will be the result if the EXFMT operation code is performed on the record format CTLR? A R SUBFL A DESCRIP 101 6 1ODSPATR(UL) A DFT(’NOT FOUND’) A R CTLR SFLCTL(SUBFL) A N50 SFLDSP A SFLDSPCTL A SFLINZ A 67 SFIJEND A SFLSIZ(13) A SFLPAG(12) A ACCOUNTNO 100 S 10
- Only AccountNo will display
- SUBFL will be initialized with 13 blank records
- An I/O exception error will occur
- The screen will display 12 records with ‘NOT FOUND’