- Which of the following is true about Java Networking API?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 import java.net.*; 2 public class Test { 3 public static void main(String[] args) throws Exception { 4 InetAddress addr = InetAddress.getByName("eduinq.com"); 5 System.out.println(addr.getHostName()); 6 } 7 } View Answer
Correct answer: A — eduinq.com
- Which of the following is true about Socket class?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 import java.net.*; 2 public class Test { 3 public static void main(String[] args) throws Exception { 4 URL url = new URL("http://eduinq.com"); 5 System.out.println(url.getProtocol()); 6 } 7 } View Answer
Correct answer: A — http
- Which of the following is true about JDBC?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 import java.sql.*; 2 public class Test { 3 public static void main(String[] args) throws Exception { 4 Class.forName("com.mysql.cj.jdbc.Driver"); 5 System.out.println("Eduinq JDBC Loaded"); 6 } 7 } View Answer
Correct answer: A — Eduinq JDBC Loaded
- Which of the following is true about PreparedStatement?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 import java.sql.*; 2 public class Test { 3 public static void main(String[] args) throws Exception { 4 Connection con = DriverManager.getConnection("jdbc:h2:mem:eduinq"); 5 PreparedStatement ps = con.prepareStatement("SELECT 1"); 6 ResultSet rs = ps.executeQuery(); 7 rs.next(); 8 System.out.println(rs.getInt(1)); 9 } 10 } View Answer
Correct answer: A — 1
- Which of the following is true about REST APIs in Java?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 import javax.ws.rs.*; 2 @Path("/eduinq") 3 public class EduinqService { 4 @GET 5 @Produces("text/plain") 6 public String getMsg() { 7 return "Eduinq REST"; 8 } 9 } View Answer
Correct answer: A — Eduinq REST
- Which of the following is true about JSON handling in Java?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 import com.google.gson.*; 2 public class Test { 3 public static void main(String[] args) { 4 Gson gson = new Gson(); 5 String json = gson.toJson("Eduinq"); 6 System.out.println(json); 7 } 8 } View Answer
Correct answer: A — "Eduinq"
- Which of the following is true about XML handling in Java?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 import javax.xml.parsers.*; 2 import org.w3c.dom.*; 3 public class Test { 4 public static void main(String[] args) throws Exception { 5 String xml = "<eduinq>Portal</eduinq>"; 6 DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); 7 Document doc = db.parse(new java.io.ByteArrayInputStream(xml.getBytes())); 8 System.out.println(doc.getDocumentElement().getTagName()); 9 } 10 } View Answer
Correct answer: A — eduinq
- Which of the following is true about Reflection API?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 class Eduinq { 2 private String name = "Eduinq Reflection"; 3 } 4 public class Test { 5 public static void main(String[] args) throws Exception { 6 Eduinq e = new Eduinq(); 7 java.lang.reflect.Field f = Eduinq.class.getDeclaredField("name"); 8 f.setAccessible(true); 9 System.out.println(f.get(e)); 10 } 11 } View Answer
Correct answer: A — Eduinq Reflection
- Which of the following is true about Class.forName()?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 class Eduinq { 2 static { System.out.println("Eduinq Loaded"); } 3 } 4 public class Test { 5 public static void main(String[] args) throws Exception { 6 Class.forName("Eduinq"); 7 } 8 } View Answer
Correct answer: A — Eduinq Loaded
- Which of the following is true about Method class in Reflection?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 class Eduinq { 2 public void show() { System.out.println("Eduinq Method"); } 3 } 4 public class Test { 5 public static void main(String[] args) throws Exception { 6 Eduinq e = new Eduinq(); 7 java.lang.reflect.Method m = Eduinq.class.getMethod("show"); 8 m.invoke(e); 9 } 10 } View Answer
Correct answer: A — Eduinq Method
- Which of the following is true about DatagramSocket?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 import java.net.*; 2 public class Test { 3 public static void main(String[] args) throws Exception { 4 DatagramSocket ds = new DatagramSocket(); 5 System.out.println("Eduinq Datagram Ready"); 6 ds.close(); 7 } 8 } View Answer
Correct answer: A — Eduinq Datagram Ready
- Which of the following is true about URLConnection?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 import java.net.*; 2 public class Test { 3 public static void main(String[] args) throws Exception { 4 URL url = new URL("http://eduinq.com"); 5 URLConnection conn = url.openConnection(); 6 System.out.println(conn.getURL()); 7 } 8 } View Answer
Correct answer: A — http://eduinq.com
- Which of the following is true about JDBC transactions?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 import java.sql.*; 2 public class Test { 3 public static void main(String[] args) throws Exception { 4 Connection con = DriverManager.getConnection("jdbc:h2:mem:eduinq"); 5 con.setAutoCommit(false); 6 System.out.println(con.getAutoCommit()); 7 } 8 } View Answer
Correct answer: A — false
- Which of the following is true about REST annotations in JAX RS?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 import javax.ws.rs.*; 2 @Path("/eduinq") 3 public class EduinqResource { 4 @POST 5 @Produces("text/plain") 6 public String postMsg() { 7 return "Eduinq POST"; 8 } 9 } View Answer
Correct answer: A — Eduinq POST
- Which of the following is true about JSON parsing with Jackson?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 import com.fasterxml.jackson.databind.*; 2 public class Test { 3 public static void main(String[] args) throws Exception { 4 ObjectMapper mapper = new ObjectMapper(); 5 String json = "{\"name\":\"Eduinq\"}"; 6 java.util.Map map = mapper.readValue(json, java.util.Map.class); 7 System.out.println(map.get("name")); 8 } 9 } View Answer
Correct answer: A — Eduinq
- Which of the following is true about JAXB?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 import javax.xml.bind.annotation.*; 2 @XmlRootElement 3 class Eduinq { 4 public String name = "Eduinq JAXB"; 5 } View Answer
Correct answer: A — Eduinq JAXB (when marshalled)
- Which of the following is true about Reflection constructors?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 class Eduinq { 2 public Eduinq() { System.out.println("Eduinq Constructor"); } 3 } 4 public class Test { 5 public static void main(String[] args) throws Exception { 6 java.lang.reflect.Constructor<Eduinq> c = Eduinq.class.getConstructor(); 7 Eduinq e = c.newInstance(); 8 } 9 } View Answer
Correct answer: A — Eduinq Constructor
- Which of the following is true about Reflection annotations?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 import java.lang.annotation.*; 2 @Retention(RetentionPolicy.RUNTIME) 3 @interface EduinqAnno {} 4 @EduinqAnno 5 class Eduinq {} 6 public class Test { 7 public static void main(String[] args) { 8 boolean present = Eduinq.class.isAnnotationPresent(EduinqAnno.class); 9 System.out.println(present); 10 } 11 } View Answer
Correct answer: A — true
- Which of the following is true about dynamic proxies?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 import java.lang.reflect.*; 2 interface Eduinq { 3 void show(); 4 } 5 class Handler implements InvocationHandler { 6 public Object invoke(Object proxy, Method m, Object[] args) { 7 System.out.println("Eduinq Proxy"); 8 return null; 9 } 10 } 11 public class Test { 12 public static void main(String[] args) { 13 Eduinq e = (Eduinq) Proxy.newProxyInstance( 14 Eduinq.class.getClassLoader(), 15 new Class[]{Eduinq.class}, 16 new Handler()); 17 e.show(); 18 } 19 } View Answer
Correct answer: A — Eduinq Proxy
- Which of the following is true about URLClassLoader?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 import java.net.*; 2 import java.net.URLClassLoader; 3 public class Test { 4 public static void main(String[] args) throws Exception { 5 URL[] urls = {}; 6 URLClassLoader loader = new URLClassLoader(urls); 7 System.out.println("Eduinq Loader Ready"); 8 } 9 } View Answer
Correct answer: A — Eduinq Loader Ready
- Which of the following is true about Proxy class in Reflection?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 import java.lang.reflect.*; 2 interface Eduinq { 3 void run(); 4 } 5 class EduinqHandler implements InvocationHandler { 6 public Object invoke(Object proxy, Method m, Object[] args) { 7 System.out.println("Eduinq Dynamic Run"); 8 return null; 9 } 10 } 11 public class Test { 12 public static void main(String[] args) { 13 Eduinq e = (Eduinq) Proxy.newProxyInstance( 14 Eduinq.class.getClassLoader(), 15 new Class[]{Eduinq.class}, 16 new EduinqHandler()); 17 e.run(); 18 } 19 } View Answer
Correct answer: A — Eduinq Dynamic Run
- Which of the following is true about ClassLoader hierarchy?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 class Eduinq { 2 static { System.out.println("Eduinq Static Block"); } 3 } 4 public class Test { 5 public static void main(String[] args) throws Exception { 6 Class<?> c = Class.forName("Eduinq"); 7 } 8 } View Answer
Correct answer: A — Eduinq Static Block
- Which of the following is true about Introspector in JavaBeans?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 import java.beans.*; 2 class Eduinq { 3 private String name; 4 public String getName() { return name; } 5 public void setName(String name) { this.name = name; } 6 } 7 public class Test { 8 public static void main(String[] args) throws Exception { 9 BeanInfo info = Introspector.getBeanInfo(Eduinq.class); 10 for(PropertyDescriptor pd : info.getPropertyDescriptors()) { 11 if(pd.getName().equals("name")) { 12 System.out.println("Eduinq Bean Property Found"); 13 } 14 } 15 } 16 } View Answer
Correct answer: A — Eduinq Bean Property Found
- Which of the following is true about ServiceLoader?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 import java.util.*; 2 public interface EduinqService { 3 void run(); 4 } 5 public class Test { 6 public static void main(String[] args) { 7 ServiceLoader<EduinqService> loader = ServiceLoader.load(EduinqService.class); 8 for(EduinqService s : loader) { 9 s.run(); 10 } 11 System.out.println("Eduinq ServiceLoader Done"); 12 } 13 } View Answer
Correct answer: A — Eduinq ServiceLoader Done (after running implementations)
- Which of the following is true about Annotation Processing?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 import java.lang.annotation.*; 2 @Retention(RetentionPolicy.RUNTIME) 3 @interface EduinqAnno { 4 String value(); 5 } 6 @EduinqAnno("Portal") 7 class Eduinq {} 8 public class Test { 9 public static void main(String[] args) { 10 EduinqAnno a = Eduinq.class.getAnnotation(EduinqAnno.class); 11 System.out.println(a.value()); 12 } 13 } View Answer
Correct answer: A — Portal