Java Programming Fundamentals
Test your knowledge of Java programming concepts including collections, generics, inheritance, operators, and language syntax.
Questions
Which of the following is not a reserved keywords?
- public
- static
- void
- main
What is the value of the expression (1 / 2 + 3 / 2 + 0.1)?
- 1
- 1.1
- 1.6
- 2.1
1.Set s = new TreeSet(); 2.s.add("JAVA"); 3.s.add(new Integer(5)); Line 3 will give ClassCast Exception because Two different types of object are getting added.
- True
- False
Which of the following operators can be used both as an integer bitwise operator and a boolean logical operator?
- ^
- !
- &
- |
Which one of these is a valid method declaration?
- void method1 { /* ... */ }
- void method2() { /* ... */ }
- void method3(void) { /* ... */ }
- method4() { /* ... */ }
Any problem in generic code is handled at Runtime.
- True
- False
Which one of the following class definitions is a valid definition of a class that cannot be extended?
- abstract class Link { }
- native class Link { }
- final class Link { }
- abstract final class Link { }
Which of these combinations of switch expression types and case label value types are legal within a switch statement?
- switch expression of type int and case label value of type char
- switch expression of type float and case label value of type int
- switch expression of type byte and case label value of type float
- switch expression of type char and case label value of type long
Which statements are true?
- {{}} is a valid statement block
- { continue; } is a valid statement block
- block: { break block; } is a valid statement block
- block: { continue block; } is a valid statement block
List l = new Arraylist(); if you use this line in your code what will we get?
- Compilation error.
- Runtime error
- Compiles Fine
- Depends on the code where you use
Which statements are true?
- Inheritance defines a has-a relationship between a superclass and its subclasses
- Every Java object has a public method named equals
- A class can extend any number of other classes
- A non-final class can be extended by any number of classes
public void addAnimal(List animals) { animals.add(new Dog()); } it's NOT legal to add when we use Wildcard character .(True/ False)
- True
- False
public void addAnimal(List animals) { animals.add(new Dog()); } it's NOT legal to add when we use Wildcard character .(True/ False)
- True
- False
List l = new Arraylist(); if you use this line in your code what will we get?
- Runtime error.
- Depends on the code where you use
- Compiles Fine
- Compilation error.
1.Set s = new HashSet(); 2.s.add("JAVA"); 3.s.add(new Integer(5)); Line 3 will give ClassCast Exception because Two different types of object are getting added.
- True
- False
1.Set s = new TreeSet(); 2.s.add("JAVA"); 3.s.add(new Integer(5)); Line 3 will give ClassCast Exception because Two different types of object are getting added.
- True
- False
1.Set s = new HashSet(); 2.s.add("JAVA"); 3.s.add(new Integer(5)); Line 3 will give ClassCast Exception because Two different types of object are getting added.
- True
- False
1.Set s = new TreeSet(); 2.s.add("JAVA"); 3.s.add(new Integer(5)); Line 3 will give ClassCast Exception because Two different types of object are getting added.
- True
- False
1.Set s = new TreeSet(); 2.s.add("JAVA"); 3.s.add(new Integer(5)); Line 3 will give ClassCast Exception because Two different types of object are getting added.
- True
- False
1.Set s = new TreeSet(); 2.s.add("JAVA"); 3.s.add(new Integer(5)); Line 3 will give ClassCast Exception because Two different types of object are getting added.
- True
- False