Java Terminology

Introduction to Classes and Methods     1) Which is used to get the value of the instance variables?         Ans: Dot notation.     2) The new operator creates a single instance named class and returns a reference to that object.         a)True         b)False         Ans: a.     3) A class is a template for…

Java String Basics

String Handling     1) Which package does define String and StringBuffer classes?         Ans : java.lang package.     2) Which method can be used to obtain the length of the String?         Ans : length( ) method.     3) How do you concatenate Strings?         Ans : By using ” + ” operator.     4)…

Java Packages-2

Networking Concepts     1) The API doesn’t list any constructors for InetAddress- How do I create an InetAddress instance?         ANSWER : In case of InetAddress the three methods getLocalHost, getByName, getByAllName can be used to create instances.         E.g.         InetAddress add1;         InetAddress add2;         try{         add1 = InetAddress.getByName(“java.sun.com”);         add2 =…

Java Packages

Java.lang     1) java.lang package is automatically imported into all programs.             True             False         Ans : a     2) What are the interfaces defined by java.lang?         Ans : Cloneable, Comparable and Runnable.     3) What are the constants defined by both Flaot and Double classes?         Ans : MAX_VALUE,         MIN_VALUE,        …

Java Featurs

Exception Handling     1) What is the difference between ΓÇÿthrowΓÇÖ and ΓÇÿthrowsΓÇÖ ?And itΓÇÖs application?         Ans : Exceptions that are thrown by java runtime systems can be handled by Try and catch blocks. With throw exception we can handle the exceptions thrown by the program itself. If a method is capable of causing an…

Java Basics

Java is one of the most popular and widely used programming language and platform. A platform is an environment that helps to develop and run programs written in any programming language. Java is fast, reliable and secure. From desktop to web applications, scientific supercomputers to gaming consoles, cell phones to the Internet, Java is used…