Java and Python Programming Fundamentals Quiz
Test your knowledge of Java and Python programming concepts including OOP, collections, string manipulation, operators, and language-specific behaviors.
Questions
By using which method ,How can one increase size of an ArrayList?
- incSize(int minCapacity)
- ensureCapacity(int minCapacity)
- incCapicity(int minCapacity)
- All of the Above
what a Clone method returns in ArrayList?
- Returns String
- Returns an Array
- Returns a shallow copy of this ArrayList instance
- Returns Void
Is Abstract Class is Parent Class of ArrayList?
- True
- False
Python lists are mutable
- True
- False
name=[1]*3
- [11]
- syntax error
- [1,1,1]
- runtime error
a=['a','b'] x=[a,'y']
- x[0][0]
- Syntax error at line 1
- Syntax error at line 2
- runtime error
x=[1,2,3,4,5] print x[-1]
- error
- 5
- garbage number
- 3
x=[1,2,3,4,5] x[3:3]='sagar' print x
- error
- [1,2,3,4,'sagar',5]
- [1,2,3,'sagar']
- none
If you run the code below, what gets printed out? String s=new String("Bicycle"); int iBegin=1; char iEnd=3; System.out.println(s.substring(iBegin,iEnd));
- Bic
- ic
- icy
- error: no method matching substring(int,char)
What does the following paint( ) method draw?
- A circle at (100, 100) with radius of 44
- A circle at (100, 44) with radius of 100
- A circle at (100, 44) with radius of 44
- The code does not compile
Which of the following statements are true
- When you construct an instance of File, if you do not use the filenaming semantics of the local machine, the constructor will throw an IOException.
- When you construct an instance of File, if the corresponding file does not exist on the local file system, one will be created.
- When an instance of File is garbage collected, the corresponding file on the local file system is deleted.
- None of the above.
Which of these are not legal identifiers. Select all the correct answers.
- 1alpha
- _abcd
- xy+abc
- transient
- account-num
- very_long_name
What gets printed on the standard output when the class below is compiled and executed. Select the one correct answer. public static ShortCkt { public static void main(String args[]) { int i = 0; boolean t = true; boolean f = false, b; b = (t && ((i++) == 0)); b = (f && ((i+=2) > 0)); System.out.println(i); } }
- 0
- 1
- 2
- 3
Is it possible to have a virtual destructor?
- True
- False
interface my_interface{ public void show(); } public class test08 { public static void main(String[] args) { my_interface mi = new B(); mi.show(); } } class A implements my_interface{ public void show(){ System.out.println("This is implemented method "); } } class B extends A{ public void show(){ System.out.println("This is overrided method "); } } What is the output
- This is implemented method
- This is overrided method
- Compile time Error
- Run time error
By default any class would be supplied with?
- Constructor
- Destructor
- Overloaded assignment operator
- Default Copy Constructor
public class Change { public static void main(String args[]) { System.out.println(2.00 - 1.10); } } What is the output
- 0.9
- 0.90
- It varies
- None of the above
public class test08 { public static void main(String[] args) { final int start = Integer.MAX_VALUE - 100; final int end = Integer.MAX_VALUE; int count = 0; for (int i = start; i <= end; i++) count++; System.out.println(count); } } What will be the output
- 100
- 101
- 102
- None of the above
class A{ public void show(){ System.out.println("This is A"); } class B extends A{ protected void show(){ System.out.println("This is B"); } public class Main{ public static void main(String[] args) { A a = new B(); a.show(); } } What is the output
- This is A
- This is B
- Nothing will be printed as output
- None of the above
public class test08 { public static void main(String[] args) { System.out.print("H" + "a"); System.out.print('H' + 'a'); } } What is the output?
- HaHa
- Ha
- Compile error
- None of the above