OOP
How to represent end of file in java?
-1
To run a compiled Java program, the machine must have what loaded and running?
JVM
who invented java?
James Gosling
What are the passive control that do not support any interaction with the user
Labels
which type of data is used to enter the value ("Welcome")?
String
Java is also known as ...... stage language
Three
The smallest integer data type
byte
stream contains the classes which can work on character stream.
character Stream
public char[] readPassword() belongs to which class.
console class
A method of ObjectIntputStream class used to read the object from input stream as required.
readObject
all java programming statements must end with a __
semicolons
What method can set or changed the text in a label.
setText()
Java uses ___ to represent characters
unicode
In java Char allocate how many bit?
16 bit
java was first developed in ___
1990
What is y after the following switch statement is executed? int x = 3; int y = 4; switch (x + 3) { case 6: y = 0; case 7: y = 1; default: y += 1;
2
What value will be printed after executing following code snippet? String text="Hello World!"; int index= text.indexOf("llo"); System.out.println(index);
2
what is size of integer in java programming
4 bytes or 32 bits
stream contains the classes which can work on character stream
Character Stream
Messages that change an object's state are called _____
Mutator
The purpose of an ________ is to pass information to a method
actual parameter
How to convert a character variable 'ch' into string? a. ch.toString(); b. Character.toString(ch); c. toString(ch); d. String.toString(ch);
b. Character.toString(ch);
which of the following statement is not correct? a. we can use the new operator on int to create an "int" object. b. variables of type "String" can be assigned a value just after being declared. c. we can use a new operator on string to create a string object d. variables of type int can be assigned a value just by being declared
c. we can use a new operator on string to create a string object
after compilation of java class the file create is
class
What is the output of the given codes? public class Main { public static void main(String[] args) { int x = 10; int y = 9; System.out.println(x > y); // returns true, because 10 is higher than 9 } }
true
The PrintStream class provides methods to?
write data to another stream
what is the value of y when the code below is executed? int x=4 int y = (int)Math.ceil(x%5 + x/5.0)
5
generated when the source code is successfully compiled ?
Bytecode
What is the output of the given codes? public class Main { public static void main(String[] args) { int time = 19; if (time < 8) { System.out.println("Good morning!!!"); } else if (time < 24) { System.out.println("Good da!!!."); } else { System.out.println("Good evening!!!"); } } }
Good da!!!.
used to converts the byte-oriented stream into character-oriented stream?
InputStreamReader
class First { void display() { System.out.println("Inside First"); } } class Second extends First { void display() { System.out.println("Inside Second"); } } class Test { public static void main(String[] args) { First obj1 = new First(); Second obj2 = new Second(); First ref; ref = obj1; ref.display(); ref = obj2; ref.display(); } }
Inside First Inside Second
what ia the full form of jdk
Java Development Kit
A variables within a class but outside any method.
Local variables
Can we access private class outside the package
No
Java is pure object oriented language?
No
main method parameter has which type of data type
String
in the hierarchy of java classes, if class A is immediately above class B, then class A is the ______ of class B.
Superclass
Which are the ways to read data from the keyboard? a. all choices are correct b. InputStreamReader c. Console d. DataInputStream
a. all choices are correct
which of these class is not related to input and output stream in terms of functioning. a. Inputstream b. file c. reader d. write
b. File
Which of the following is not a valid type in Java? a. float b. static c. void d. int
b. static
A stream is a sequence of data. In Java a stream is composed of?
bytes
which of these class is not a member class of java.io.package? a. file b. StringReader c. String d. Writer
c. String
What will this code print? int arr[] = new int [5]; System.out.print(arr); a. Garbage value b. blank c. null d. value stored in arr[0]
c. null
What will be printed by following code snippet? char ch='a'; System.out.println(Character.toUppercase("value is: "+ch)); a. value is: b. value is: A c. value is: a d. Error
d. Error
Which of the following statements can provide the output "180"? a. String str = "CS180"; System.out.print(str.substring(3, 5)); b. String str = "P"; System.out.print(str.length() + 80); c. String str = "CS180"; System.out.print(str.substring(2, 4)); d. String str = "P"; System.out.print(str.length() + "80");
d. String str = "P"; System.out.print(str.length() + "80");
What will be the output of following program? public class temp { public static void main(String agrs[]) { for(int i=1, int j=1; i<5 ; i++, j++) System.out.print(i+""+j); } }
error
What is the output of the given codes? public class Main { public static void main(String[] args) { int x = 5; int y = 3; System.out.println(x == y); } }
false
a _____ is declared in order to have temporary working storage for data in a method
local variable
A FileReader class is used to read characters from file.
read
an object _____ as defined by the method of it class
state
What is the value of variable result? int result = 0; int index = 0; while (true) { ++index; if (index % 2 == 0) continue; else if (index % 5 == 0) break; result *= 3; }
0
public class ContinueExample2 { What is the output of the given codes?public static void main(String[] args) { for(int i=1;i<=3;i++){ for(int j=1;j<=3;j++){ if(i==2&&j==2){ continue; } System.out.print(i+" "+j); } } } }
1 11 21 32 12 33 13 23 3
Which of the following are valid calls to Math.max? 1. max(1,4) 2. max(2.3, 5) 3. max(1, 3, 5, 7) 4. max(-1.5, -2.8f)
1,2, and 4
Guess the output. String x = "10"; String y= "20"; String z = x+y; System.out.println(z);
1020
guess the output. int i; for(i=1; i<=10; i++); System.out.print(i);
11
What will be the output of following program? public class temp { public static void main(String agrs[]) { for(int i=1, j=1; i<5 ; i++, j++) System.out.print(i+""+j); } }
11223344
What will be the output of the following Java program? class selection_statements { public static void main(String args[]) { int var1 = 5; int var2 = 6; if ((var2 = 1) == var1) System.out.print(var2); else System.out.print(++var2); } }
2
Consider the given code snippet and select the correct answer. for(int i=1, j=1; i<5 ; i++, j++) System.out.print(i+j);
2468
How many times "Hello world!" will be printed? (Consider the following code snippet). int x = 2; int y = 8; while(x<(y+5)) { System.out.println("Hello world!"); x+=2; y-=2; }
3
What is the output of this program? class Output { public static void main(String args[]) { double x = 2.0; double y = 3.0; double z = Math.pow( x, y ); System.out.print(z); } }
8.0
class is used for this Processing Method process ActionEvent()
Button, List, MenuItem
A(n) _______ is a software package that describes the characteristics of similar objects.
Class
What will be the output of following program? public class temp { public static void main(String agrs[]) { for(int i=1, int j=1; i<5 ; i++, j++) System.out.print(i+""+j); } }
Error
What will be the output of following program? public class temp { public static void main(String agrs[]) { for(int i=1; i<=10; i++); System.out.print(i); } }
Error
What is used for writing data to a file in file handling
FileOutputStream
The process of creating a new object is called ___
Instantiation
A class contains the methods print() & println()
PrintStream
The access specifiers can be used for an interface
Public
What is class variable? a. class variables are static variables within a class but outside any method. b. class variables are variables within a class but outside any method. c. no correct answer d. class variables are variables defined inside methods, constructors or blocks.
a. class variables are static variables within a class but outside any method.
Which of the following code displays the area of a circle if the radius is positive. a. if (radius > 0) System.out.println(radius * radius * 3.14159); b. if (radius <= 0) System.out.println(radius * radius * 3.14159); c. if (radius >= 0) System.out.println(radius * radius * 3.14159); d. if (radius != 0) System.out.println(radius * radius * 3.14159);
a. if (radius > 0) System.out.println(radius * radius * 3.14159);
Analyze the following code: Code 1: int number = 45; boolean even; if (number % 2 == 0) even = true; else even = false; Code 2: boolean even = (number % 2 == 0); a. Code 2 has compile errors. b. Both Code 1 and Code 2 are correct, but Code 2 is better. c. Both Code 1 and Code 2 have compile errors. d. Code 1 has compile errors.
b. Both Code 1 and Code 2 are correct, but Code 2 is better.
Suppose income is 4001, what is the output of the following code? if (income > 3000) { System.out.println("Income is greater than 3000"); } else if (income > 4000) { System.out.println("Income is greater than 4000"); } a. Income is greater than 4000 b. Income is greater than 3000 c. Income is greater than 3000 followed by Income is greater than 4000 d. no output
b. Income is greater than 3000
Analyze the following code and choose the correct answer. int[] arr = new int[5]; arr = new int[6]; a. The code has runtime errors because the variable arr cannot be changed once it is assigned b. The code can compile and run fine. The second line assigns a new array to arr c. The code has compile errors because the variable arr cannot be changed once it is assigned d. The code has compile errors because we cannot assign a different size array to arr
b. The code can compile and run fine. The second line assigns a new array to arr
Which of these is true of the relationship between objects and classes? a. an object is the ancestor of its subclass b. an object is an instance of a class c. an object is the descendant of its superclass d. a class is an instance of an object
b. an object is an instance of a class
which is a reserved word in the java programming language? a. native b. class c. subclasses d. method
b. class
java language has support for which of the following types of comments.
block, line, and javadoc
class Test { public static void main(String[] args) { int x = 10; if (++x < 10 && (x / 0 > 10)) { System.out.println("Bishal"); } else { System.out.println("GEEKS"); } } } a. Compile time error b. Bishal c. GEEKS d. RuntimeException:ArithmeticException: / by zero
c. GEEKS
Which of these is an incorrect Statement? a. Array can be initialized when they are declared b. Array can be initialized using comma separated expressions surrounded by curly braces c. It is necessary to use new operator to initialize an array d. no correct answer
c. It is necessary to use new operator to initialize an array
Analyze the following code. boolean even = false; if (even) { System.out.println("It is even!"); } a. The code is wrong. You should replace if (even) with if (even = true). b. The code is wrong. You should replace if (even) with if (even == true). c. The code displays nothing. d. The code displays It is even!
c. The code displays nothing.
The compulsory section of java program
class declaration section
The compulsory section of java program.
class declaration section
What method is used to close a stream?
close()
the purpose of an ____ is to initialize the instance variables of a newly instantiated object.
constructor
Analyze the following code fragments that assign a boolean value to the variable even. Code 1: if (number % 2 == 0) even = true; else even = false; Code 2: even = (number % 2 == 0) ? true: false; Code 3: even = number % 2 == 0; a. Code 2 has a compile error, because you cannot have true and false literals in the conditional expression. b. All three are correct, but Code 3 is preferred. c. Code 3 has a compile error, because you attempt to assign number to even d. All three are correct, but Code 1 is preferred.
d. All three are correct, but Code 1 is preferred.
Which of the following is False about Java Streams? a. Stream does not store elements. It simply conveys elements from a source such as a data structure, an array, or an I/O channel, through a pipeline of computational operations. b. Stream is functional in nature. Operations performed on a stream does not modify it's source. c. The elements of a stream are only visited once during the life of a stream. Like an Iterator, a new stream must be generated to revisit the same elements of the source. d. Streams are only used for file operations.
d. Streams are only used for file operations.
Analyze the following program fragment: int x; double d = 1.5; switch (d) { case 1.0: x = 1; case 1.5: x = 2; case 2.0: x = 3;} a. No errors. b. The program has a compile error because the required default case is missing in the switch statement. c. The program has a compile error because the required break statement is missing in the switch statement. d. The switch control variable cannot be double
d. The switch control variable cannot be double
the combining of data and behavior into a single software package is called _____
encapsulation
What is the output of the following code if the input string is "CS 180"? Scanner scanner = new Scanner(); String str; str = scanner.next(); System.out.println(str);
error
true or false. Swing is not a part of JFC that is used to create GUI application
false
Which of the following method(s) not included in InputStream class. a. reset( ) b. close( ) c. available( ) d. flush( )
flush()
The package contain classes and interface used for input & output operations of a program
java.io
event class is defined in which of the libraries.
java.lang
string contain in which package
java.lang
which object can be constructed to show any number of choices in the visible window
list
all java application must have method named?
main
the old name of java was ___
oak
what is the base class of all classes.
object class
Java programs are
platform independent
A method of ObjectIntputStream class used to write the object to output stream as required
writeObject
A method of ObjectIntputStream class used to write the object from output stream as required.
writeObject()