Course details
This course is for anyone who wants to test or brush up their core Java skills or face java interviews.
Java is the most popular language world wide and technologies like Servlets & JSP, J2EE, Struts, Spring, Hibernate, JMS or android for mobile applications are all based on core Java.
Quizzes cover following topics:-
- Java syntax and grammar
- Javadoc and developer comments and their significance.
- Variables, Data Types and Operators
- Control Statements: if-else, switch-case and loops
- Java arrays and Command-line arguments
- Packages, classpath and User-input using Scanner
- Classes, objects, constructors, initialization blocks, type of variables, methods and Garbage collection
- Object Oriented Programming Concepts:
- Encapsulation
- Inheritance
- Polymorphism
- Abstraction
- Access specifier, instanceof operator and casting
- String, StringBuilder and Wrapper classes
- Exception
- Enumeration
Q1: What will be the result of compiling and executing following program?
//Test1.javaclass Vehicle { public int getRegistrationNumber() { return 1; }}class Car { public int getRegistrationNumber() { return 2; }}public class Test1 { public static void main(String[] args) { Vehicle obj = new Car(); System.out.println(obj.getRegistrationNumber()); }}
A. 1
B. 2
C. An exception is thrown at runtime.
D. Compilation error.
Answer: D
Q2: Below is the code of Test06.java file.
What will be the result of compiling and executing following program by using the command java Test06 RED AMBER
public class Test06 { enum TrafficLight { RED, YELLOW, GREEN; } public static void main(String[] args) { TrafficLight tl = TrafficLight.valueOf(args[1]); switch(tl) { case TrafficLight.RED: System.out.println("STOP"); break; case TrafficLight.YELLOW: System.out.println("SLOW"); break; case TrafficLight.GREEN: System.out.println("GO"); break; } }}
A. STOP
B. No output
C. IllegalArgumentException is thrown
D. None of the above
Answer: D
Q3: What will be the result of compiling and executing following program?
public class Test5 { public static void m1() { System.out.println("static method."); } public static void main(String[] args) { Test5 obj = null; obj.m1(); }}
A. NullPointerException is thrown.
B. Compilation error.
C. static method.
D. None of the above.
Answer: C
Programming Related Questions
- JavaScript Full stack web developer virtual internship Virtual Bootcamp + Internship at LaimoonAED 1,449Duration: Upto 30 Hours
- Learn C++ from Scratch- CPD Certified Academy for Health & FitnessAED 799Duration: Upto 110 Hours
- Coding (Computer Programming) NextGen LearningAED 469Duration: Upto 20 Hours