Download Java Programming - E

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Nehru Arts and Science College
Department of Computer Applications
Subject Name :JavaProgramming
Subject Code: 43B
Semester: IV
Staff Name: R.RajaPriya & N.P.Shiju
JAVA PROGRAMMING – UNIT - I
1
Object=
(1) A) Data + Methods (2) data + statement (3) Data + Object (4) None
2
Object oriented programming follows---- programming approach
(1) a) Bottom up (2) top-down (3) Both (4) None
3
The wrapping of data and function in to a single unit is called as----(1) Polymorphism (2) encapsulation (3) data hiding (4)both a and b
4
Reusability of OOP can be achieved through ---(1) a) Class (2) polymorphism (3) inheritance (4) all the above
5
Who is the developer of java
(1) E.Balagurusamy (2) strosstrup (3) James goasling (4) None
6
Say true or false java is compiled and interpreted
(1) True (2) false (3) dont know (4) none
7
Which one of the following statements can be included in Java
(1) goto (2) size of (3) typedef (4) Break
8
say true or false: java support operator overloading
(1) None (2) dont know (3) true (4) false
9
Hot java is a---(1) Compiler (2) interpreter (3) web browser (4) None
10
Byte code of java is created by
(1) Java compiler (2) java interpreter (3) hot java (4)none
Expansion of API is ---11 (1) Application path interface (2) applet programming interface (3) application
programming interface (4)None
12
Math class in java is used to include----(1) Basic input & output (2) mathematical calculation (3)utilities (4) None
13
Grouping a classes in to a single unit is called
(1) Base class (2) derived class (3) procedure (4)package
14
The smallest individual unit of a program is called as
(1) Tokens (2) blocks (3) class (4) None
15
Sequence of characters that represent constant values is called---(1) Variables (2) statements (3) literals (4) all the above
16
---- is used to indicate where group of codes are divided and arranged
(1) Operator (2) label (3) object (4) separator
17
If and if else statement in java is -----type of statements
(1) jump statement (2) expression statement (3) labeled statement (4) selection statement
18
----- java statement is used to handle issues with multithreading
(1) Guarding statement (2) labeled statement (3)synchronization statement (4) none
19
The combination of operator and operands is called as-----(1) Identifiers (2) literals (3) seperators (4) statements
20
Which type of java programming supports internet application
(1) Application programming (2) applet programming (3) both (4) None
21
Passing arguments at run time is called ----(1) Command line argument (2) compile time argument (3) runtime argument (4) None
22
Say true or false byte code is understandable by machine
(1) False (2) true (3) dont know (4) none
23
Java originally called as --(1) oak (2) oak java (3) java (4) None
24
The name of the team developed java is ---(1) Red project team (2) green project team (3) yellow project team (4) None
25
Expand JVM
(1) Java virtual machine (2) java vital machine (3) java virtue macine (4) None
SECTION-B
1.Write down the basic structure of Java program.
2.List the applications of Object-Oritented programming
3.List out the benefits of OOP.
4.Write a note on Java Virtual Machine.
5.Write note on Java features.
6.Write note on Applicatons of Java
SECTION-C
1Explain about the basic concepts of oops.
2.Describe about the web browsers.
3.Discuss in detail about Java Virtual Machine
4.Explain about how to implement java program
5.Explain about scope of variables.
6.Discuss about Java Operators.
JavaProgramming - Unit – II
1. ----performs a set of operations repeatedly until the control variable fails to satisfy the test
condition
(1) if..else (2) Loops (3) goto
2. Objects in java are created using the ___operator
(1) dot (2) ?: (3) new
3. The keyword ____signifies that the properties of the superclassname are extended to the
subclassname
(1) auto (2) extends (3) continue
4. A class that cannot be subclassed is called ----
(1) method (2) final (3) hidden
5. ----fields enjoy the highest degree of protection
(1) private (2) protect (3) public
6. __accessibility known as friendly level of access
(1) visible (2) public (3) private
7. How many bytes are required for float data type
(1) 8 (2) 4 (3) 2
8. Instance and class variables are declared --------in the class
(1) Out side (2) inside (3) global
9. An object is -----
(1) Class (2) runtime entity (3) both
10. Does java supports operator overloading
(1) Yes (2) No (3) Sometimes
11. class Equals { public static void main(String [] args) { int x = 100; double y = 100.1;
boolean b = (x = y); /* Line 7 */ System.out.println(b); } }
(1) true (2) false (3) Compilation fails
12. Which is valid declaration of a float?
(1) float f = 1F; (2) float f = 1.0; (3) float f = "1";
13. What is the numerical range of char?
(1) 0 to 32767 (2) 0 to 65535 (3) -256 to 255
14. Which of the following are Java reserved words?
(1) run (2) import (3) default
15. Which will legally declare, construct, and initialize an array?
(1) int [] myList = {"1", "2", "3"}; (2) int [] myList = (5, 8, 2); (3)int myList [] = {4, 3,
7};
16. Which is a reserved word in the Java programming language?
(1) native (2) method (3) subclasses
17. Which is a valid keyword in java?
(1) string (2) interface (3) Float
18. Which of the following statements about the Java language is true?
(1) Java supports only Procedural approach towards programming(2) Java supports only
Object Oriented Programming approach (3) Both Procedural and Object Oriented
Programming are supported in Java
19. Java is an enhanced version of C++
(1) True (2) False (3) sometimes
20. JRE stands for
(1) Java Real Environment (2) Java Runtime Environment (3)Java Rapid Enterprise
21. Java source codes are compiled and converted to
(1) Objectcodes (2) Assemblycodes (3) Bytecodes
22. What is the Extension of java bytecodes?
(1) .class (2) .java (3) .bc
23. What is the command to compile a java program? (Let the file name be myprogram.java)
(1) java myprogram.java (2) java myprogram (3) javac myprogram.java
24. Garbage collection takes place automatically in JVM.
(1) True (2) false (3) runtime
25. What are the pillars of OOPS concept?
(1) Atomicity, Inheritance, Encapsulation, Polymorphism (2)Abstraction, Inheritance,
Polymorphism (3)Abstraction,Inheritance, Encapsulation, Polymorphism
Section – B
1. Give a note on real constants with examples
2. what are the data types available in java
3. Discuss the fundamentals of class
4. Write about the looping statements
Section – C
1. Explain the different types of operators in Java
2. How do you access class members ? explain
3. describe the visibility of java method,class and variables
4. Compare the all branching statements in java
JavaProgramming - Unit – III
1. Which one of these lists contains only Java programming language keywords?
(1) class, if, void, long, Int, continue (2) goto, instanceof, native, finally, default,
throws (3) byte, break, assert, switch, include
2. Which one of the following will declare an array and initialize it with five numbers?
(1) Array a = new Array(5); (2) int a [] = new int[5]; (3) int [] a = {23,22,21,20,19};
3. Which is the valid declarations within an interface definition?
(1) public double methoda(); (2) public final double methoda();(3) protected void
methoda(double d1);
4. Which is a valid declarations of a String?
(1) String s1 = null; (2) String s2 = 'null'; (3) String s3 = (String) 'abc';
5. Overloaded methods are differentiated by
(1) Number of arguments (2) Data type of arguments (3)Number and the Data type of the
arguments
6. Which keyword is used to inherit class?
(1) inherit (2) extends (3) throw
7. Which method of System class is used to copy array?
(1) copyArray (2) arrayCopy (3) arraycopy
8. Which is right way to creating an array of integer?
(1) javaArray = new int[10]; (2) int[] javaArray = new int[10];(3) Both
9. Which is right way to declare Array?
(1) int[] myArray; (2) int []myArray; (3) int () my array
10. If you access an uninitialized local variable will result?
(1) Syntax errors (2) compile time errors (3) run time errors
11. How many type of Primitive Data Types exist in Java?
(1) 8 (2) 6 (3) 2
12. A collection of methods with no implementation is called an ________.
(1) Polymorphism (2) Inheritance (3) Interface
13. Which is not a valid comment style in Java
(1) /* comment */ (2) /* comment (3) /** comment */
14. The Java programming language is a ________?
(1) High Level Language (2) Assembly Level Language (3)Machine Level Language
15. Which is not a valid keyword in java?
(1) synchronized (2) native (3) null
16. Which of the following statements is incorrect?
(1) Friend keyword can be used on main(). (2) Friend keyword can be used in the class to
allow access to another class. (3)Friend keyword can be used for a function in the private
section of a class.
17. Which of the following two entities (reading from Left to Right) can be connected by the
dot operator?
(1) A class member and a class object. (2) A class object and a member of that
class. (3) A class object and a class.
18. How can we make a class abstract?
(1) By making at least one member function as pure virtual function. (2) By declaring it
abstract using the static keyword.(3) By declaring it abstract using the virtual keyword.
19. Which of the following access specifies is used in a class definition by default?
(1) Protected (2) Public (3) Private
20. Which of the following keywords is used to control access to a class member?
(1) Protected (2) Default (3) Break
21. Which of the following also known as an instance of a class?
(1) Member Functions (2) Object (3) Friend Functions
22. Constructor is executed when _____.
(1) an object is created (2) an object is used (3) a class is declared
23. How many objects can be created from an abstract class?
(1) 0 (2) 1 (3) 2
24. What does the class definitions in following code represent? class Bike { Engine objEng;
}; class Engine { float CC; };
(1) has a relationship (2) Inheritance (3) kind of relationship
25. Which of the following statements is correct?
(1) Both data and functions can be either private or public.(2) Member functions of a
class must be private. (3) Constructor of a class cannot be private.
Section – B
1. How to initialize an array
2. Write a short note on vectors
3. How to create a user defined package in java
4. Write a program to implement a vector in java
Section – C
1. How interfaces are implemented in java? Explain it with an example
2. Explain the usage of thread priority
3. Explain the need and concept of thread synchronization
4. Discuss the implementation of Interface in java
JavaProgramming - Unit – IV
1.Which is used to handle the exceptions
(1) catch handler (2) exceptional handler (3) handler
2.What is the name of the method used to start a thread execution?
(1) start(); (2) init(); (3) run();
3. Which cannot directly cause a thread to stop executing?
(1) Calling the SetPriority() method on a Thread object. (2)Calling the wait() method on an
object. (3) Calling notify() method on an object.
4.Which two of the following methods are defined in class Thread?
(1) start() (2) run() (3) both
5.Which of the following will directly stop the execution of a Thread?
(1) wait() (2) notify() (3) notifyall()
6.Which method must be defined by a class implementing the java.lang.Runnable interface?
(1) void run() (2) public void run() (3) public void run()
7. Which method registers a thread in a thread scheduler?
(1) start(); (2) construct(); (3) run();
8. Which class or interface defines the wait(), notify(),and notifyAll() methods?
(1) Thread (2) Runnable (3) Object
9. public class MyRunnable implements Runnable { public void run() { // some code here } }
(1) new Runnable(MyRunnable).start(); (2) new Thread(new MyRunnable()).start(); (3) new
MyRunnable().start();
10. Which of the following is a checked exception?
(1) IllegalMonitorStateException (2) InterruptedException (3)IllegalArgumentException
11. public class X { public static void main(String [] args) { try { badMethod();
System.out.print("A"); } catch (Exception ex) { System.out.print("B"); } finally {
System.out.print("C"); } System.out.print("D"); } public static void badMethod() { throw new
Error(); /* Line 22 */ } }
(1) Compilation fails. (2) C is printed before exiting with an error message (3) BC is printed
before exiting with an error message.
12. Which of these keywords must be used to monitor for exceptions?
(1) try (2) catch (3) throw
13. Which of these keywords must be used to handle the exception thrown by try block in some
rational manner?
(1) finally (2) catch (3) finally
14. class exception_handling { public static void main(String args[]) { try { int a, b; b = 0; a = 5 /
b; System.out.print("A"); } catch(ArithmeticException e) { System.out.print("B"); } } }
(1) A (2) B (3) Compilation Error
15. class exception_handling { public static void main(String args[]) { try { int i, sum; sum = 10;
for (i = -1; i < 3 ;++i) sum = (sum / i); } catch(ArithmeticException e) { System.out.print("0"); }
System.out.print(sum); } }
(1) 0 (2) 02 (3) 05
16. Which one does not have a valueOf(String) method
(1) Integer (2) Boolean (3) Character
17. What is default layout manager for panels and applets?
(1) Flowlayout (2) Gridlayout (3) BorderLayout
18. The Java Program is enclosed in a class definition.
(1) True (2) False (3) compile
19. What is an example of polymorphism?
(1) Method overriding (2) Method overloading (3) Anonymous classes
20. Can you extend an interface?
(1) Yes (2) No (3) sometimes
21. Which of the following are valid statements
(1) Math.round(9.99,1); (2) Math.round(9.99,1,10); (3) None of the above.
22. Which of the following option is not true about java programming
(1) Byte code is executed by CPU. (2) Java is a platform. (3)Java is high level programming
language.
23. Which not true about API in java?
(1) It is large collection of software components. (2) It is large array of useful class. (3) API
stands for application package interface.
24. Suspend thread can be revived by using
(1) start() method (2) resume() method (3) yield() method
25. Runnable is
(1) Class (2) Method (3) Interface
Section – B
1. How exceptions are used for debugging?
2. How to draw arcs in java
3. Describe the life cycle of an applet
4. Elucidate about the exception handling during arithmetic operation
Section – C
1. Explain the different types of errors
2. Discuss in detail about applet life cycle
3. Write java program to read 10 integers elements and store it in to an array and try to
access 12th element of an array.Handle the exception if any error rises
4. Write a java program to draw the various ellipse shapes in an applet window
JavaProgramming - Unit – V
1.Which collection class associates values witch keys, and orders the keys according to their
natural order
(1) java.util.TreeMap (2) java.util.SortedSet (3)java.util.HashSet
2. Which one does not extend java.lang.Number
(1) Boolean ,Character (2) Long ,short (3) int,float
3. Which one does not have a valueOf(String) method
(1) Integer (2) double (3) Character
4. What will be the output of line 5 1 Choice c1 = new Choice(); 2 c1.add("First"); 3
c1.addItem("Second"); 4 c1.add("Third"); 5 system.out.println(c1.getItemCount());
(1) 1 (2) 3 (3) 2
5. Which one of the following does not extends java.awt.Component
(1) CheckbocGroup (2) Canvas (3) CheckBox
6. 1 Boolean b1 = new Boolean("TRUE"); 2 Boolean b2 = new Boolean("true"); 3 Boolean b3 =
new Boolean("JUNK"); 4 System.out.println("" + b1 + b2 + b3);
(1) truetruefalse (2) Comiler error (3) RunTime error
7. Who invented Java?
(1) Netscape (2) Sun (3) Microsoft
8. To run a compiled Java program, the machine must have what loaded and running?
(1) Java virtual machine (2) A Web browser (3) Java bytecode
9. A JSP is transformed into a(n):
(1) Javas (2) JavaPages (3) Java servlet.
10. What is bytecode?
(1) Machine-independent code (2) Java code (3) Machine-specific code
11. JDBC stands for:
(1) Java Database Components (2) Java Database Connectivity(3) Java Database Control
12. Which of these is used to perform all input & output operations in Java?
(1) Variables (2) streams (3) classes
13. Which of these is a type of stream in Java?
(1) Short stream (2) Long stream (3) Byte stream
14. Which of these classes are used by Byte streams for input and output operation?
(1) InputStream (2) InputOutputStream (3) Reader
15. Which of these class is used to read from byte array?
(1) BufferedInputStream. (2) ByteArrayInputStream. (3)ArrayInputStream.
16. What is the output of this program? class output { public static void main(String args[]) {
StringBuffer c = new StringBuffer("Hello"); System.out.println(c.length()); } }
(1) 5 (2) 4 (3) 3
17. What is the output of this program? class output { public static void main(String args[]) {
StringBuffer s1 = new StringBuffer("Hello"); StringBuffer s2 = s1.reverse();
System.out.println(s2); } }
(1) Hello (2) olleHHello (3) olleH
18. This section of our 1000+ Java MCQs focuses on creating threads in Java Programming
Language. What does AWT stands for?
(1) Abstract window tool kit (2) All window tool kit (3) Abstract window tech Lit
19. You read the following statement in a Java program that compiles and executes.
submarine.dive(depth); What can you say for sure?
(1) depth must be an int (2) dive must be a method. (3) dive must be the name of an instance
field.
20. Which is a not characteristic of java programming language?
(1) Robust (2) Procedural (3) Multithreaded
21. Which of them is a not command line tool?
(1) javapath (2) javaw (3) javadoc
22. Which not true about API in java?
(1) API stands for application package interface. (2) It is large collection of software
components. (3) It is large array of useful class.
23. Which of these functions is called to display the output of an applet?
(1) print() (2) displayApplet() (3) PrintApplet()
24. Which of these modifiers can be used for a variable so that it can be accessed from any
thread or parts of a program?
(1) transient (2) volatile (3) global
25. Which of these operators can be used to get run time information about an object?
(1) getInfo (2) Info (3) instanceof
Section – B
1. Give a note on byte stream classes
2. What is the need for buffering a file
3. Define and discuss about Byte Stream classes
4. Discuss about the I/O exception
Section – C
1. Briefly describe the concept of streams
2. Explain in detail about random access files
3. Explain the various Character stream classes in java
4. Write a java program to enter 20 characters into a file and read the characters form the
file and display.