Java and C++ Programming Fundamentals
Test your knowledge of core programming concepts including OOP principles, exception handling, pointers, and preprocessor directives in Java and C++.
Questions
1)main() { int i = 5; printf(“%d %d %d %d %d”,i++,i--,++i,--i,i); }
- 5 6 6 5 5
- 6 5 6 5 5
- 5 5 6 5 5
- 4 5 5 4 5
1)void main() { int const *p = 5; printf(“%d”,++(*p)); }
- 6
- junk value
- some address
- error
1)#define square(x) x*xmain(){ int i; i=64/square(4); printf(“%d”,i);}
- 32
- 4
- 64
- 16
1)main() { int a[2][3][2]={{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}}; printf(“%u %u %u %d”,a,*a,**a,***a); printf(“%u %u %u %d\n”,a+1,*a+1,**a+1,***a+1); } Provided base address of a is 100.
- 100 100 100 2 112 104 102 3
- 100 104 108 3 112 116 120 3
- 100 100 100 2 112 104 102 2
- 100 104 108 2 112 116 120 2
1)main() { static int a[]={0,1,2,3,4}; int *p[]={a,a+1,a+2,a+3,a+4}; int **ptr=p; ptr++; printf(“\n%d%d%d”ptr-p,*ptr-a,**ptr); *ptr++; printf(“\n%d%d%d”ptr-p,*ptr-a,**ptr); *++ptr; printf(“\n%d%d%d”ptr-p,*ptr-a,**ptr); ++*ptr; printf(“\n%d%d%d”ptr-p,*ptr-a,**ptr); }
- 123 234 340 012
- 111 222 333 444
- 111 222 444 333
- 012 340 234 123
Which of the following statements are valid array declaration?
- int number();
- float average[];
- double[] marks;
- counter int[];
Which of the following classes are available in the java.lang package?
- Object
- Math
- Random
- Stack
Which of the following are the wrapper classes?
- Byte
- Integer
- Short
- String
Given the code String s1 = "yes"; String s2 = "yes"; String s3 = new String(s1); Which of the following would equate to true?
- s1 == s2
- s3 == s1
- s1.equals(s2)
- s3.equals(s1)
The methods wait() and notify() are defined in
- java.lang.Thread
- java.lang.Object
- java.lang.Runnable
- java.lang.ThreadGroup
An abstract class can have an object defined.
- True
- False
virtual function defined in the parent class should be redefined in all of its inheriting child classes
- True
- False
string s="tcs". This is a valid c++ syntax.
- True
- False
Static global variable in one c++ file can be used in another c++ file with the help of extern keyword.
- True
- False
“abc” is a primitive value
- True
- False
A class is a subclass of itself.
- True
- False
Exceptions can be rethrown.
- True
- False
void is the return type of a program’s main() method
- True
- False
non-Unicode letter characters $ and _ cannot be used as the first character of an identifier
- True
- False
this() is used to invoke a constructor of the same class
- True
- False