KEMBAR78
Java | PDF | Class (Computer Programming) | Programming Paradigms
0% found this document useful (0 votes)
17 views16 pages

Java

Uploaded by

sweth8706
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views16 pages

Java

Uploaded by

sweth8706
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

01.

Which of the following defines a legal abstract class

1. abstract vehicle { abstract void display( ); }

2. abstract class Vehicle { abstract void supply( ); }

3. class abstract vehicle { abstract void supply( ); }

4. none

02. The concept of multiple inheritance is implemented in Java by

1. extending two or more classes

2. extending one class and implementing one or more interfaces

3. implementing two or more interfaces

4. both 2 and 3

03. Which of the following statements are valid array declaration

1. int num [ ] = new int [ 5 ] ;

2. float average [ ] ;

3. double [ ] marks ;

4. both 2 and 3

04. Consider the following code

int number [ ] = new int [ 5 ] ;

After execution of this statement, which of the following are true

1. number [5] is undefined

2. number [2] is 0

3. number.length ( ) is 5

4. all the above

05. What will be the content of array available table after executing the following code

for (int i = 0 ; i < 3 ; i++)

for (int j = 0 ; j < 3 ; j++)

if (i == j) table [i] [j] = 1;

else table [i] [j] = 0;

1. [ [1, 0, 0], [0, 1, 0], [0, 0, 1] ]

2. [ [0, 0, 0], [0, 0, 0], [0, 0, 0] ]

3. [ [1, 1, 1], [1, 1, 1], [1, 1, 1] ]

4. [ [0, 1, 0], [1, 0, 1], [0, 1, 0] ]


06. A class that does not define constructor has sub-classes to fill in

1. An instance

2. An abstract

3. A class

4. None of the above

07. The keyword gives a class explicit access to the constructors, methods, and variables of its second
arguments

1. final

2. super

3. instance of

4. implicit

08. ________ is a class defined in the java.lang package, whereas it is primitive data type defined in
the Java language

1. int

2. float

3. char

4. integer

09. Which of the following is not a reserved keyword in Java

1. abstract

2. boolean

3. break

4. count

10. In a method invocation, does java pass

1. arguments by reference

2. arguments by value

3. arguments by pointer

4. arguments by variable

11. Which one of the following methods must a subclass of Applet implement

1. destroy ( )

2. init ( )

3. start ( )

4. none of the above


12. Which of the following methods are never run by the applet context

1. destroy ( )

2. init ( )

3. main ( )

4. stop ( )

13. Java Virtual Machine is an interpreter for byte code

1. True

2. False

15. Java in Case

1. Sensitive

2. Insensitive

3. java

4. .class

16. The Java interpreter is used for the ___ of the source code

1. Debugging

2. Execution

3. Compiling

4. Creation

17. Which one does not extend java.lang.Number?

1. Integer

2. Boolean

3. Short

4. Long

18. What will happen if you try to compile and run the following code?

public class {

public static void main(String argv[]) {

int anar[] = new int[5];

System.out.println(anar[0]);

1. Error
2. Null

3. 5

4. 0

19. How can a class be imported to a program?

1. import "class name";

2. import "class name*";

3. import "class name*";

4. import "class name.*";

20. Applets are executed generally in a

1. Console

2. Browser

3. Server

4. Network

21. What is the O/P of the following program?

class ExampleApp {

public static void main(String[] args) {

int a = 1, b = 13;

if ((b = a + a) == (b < (a = a + a)))

b = (a = a + a);

else if ((a = a + a) < (b = a + a))

System.out.println(b - a);

else

System.out.println(b + a);

1. Compilation error

2. 14

3. 16

4. None of these

22. Which of the following comments about the program counter (PC) are true?
(A) It is a register
(B) During execution of the current instruction, its content changes
1. A and B

2. A and C

3. Only A

4. None

23. The difference between ‘ ’ and “ ” is

1. The first one refers to a variable whose identifier is and the second one refers to the
character constant

2. The first one is a character constant and second one is the string literal

3. Both are same

4. None of the above

24. What is the environment variable that contains a list of directories where Java looks for classes
referenced in a program?

1. PATHCLASS

2. SEARCHCLASS

3. PATHDIR

4. CLASSPATH

25. Regarding the use of new line character \n and endl manipulator with cout statement

1. Both ways are exactly same

2. endl can’t be used without cout

3. Both are similar but endl additionally performs flushing of buffer

4. None

26. Which can’t be used with cout.

1. Instance variable

2. Local variable

3. Class variable

4. None of the above

27. Which of the following are Java variables type


(A) Instance variable
(B) Local variable
(C) Class variable

1. A and B

2. A, B and C

3. A and C
4. None

28. Constructor is called

1. When the class is declared

2. When the object of class is created

3. When the class is defined

4. None

29. Which of the following is not a type of exception?

1. Error class

2. Checked

3. Unchecked

4. Routine

30. The main thread of Java program is controlled by

1. An object of main thread itself

2. An object of thread class

3. Runnable

4. None

31. In Java the Exception class is a subclass of

1. Error class

2. Throwable class

3. System class

4. None

32. A class variable is a variable that is declared inside a class as

1. Static

2. Abstract

3. Final

4. Extends

33. A lower priority thread can pre-empt a higher priority thread

1. True

2. A higher priority thread can pre-empt a low priority thread

3. A running thread can be pre-empted

4. None
34. ___ class is used for creating string objects which are to be changed frequently.

1. String

2. String Buffer

3. Both 1 and 2

4. None

35. To promote encapsulation, Java provides an access modifier

1. Protected

2. Private

3. Public

4. None

36. Which of the following packages is imported by default?

1. Java.io

2. Java.util

3. Java.text

4. Java.lang

37. What does the statement System.out.println(++i + 5); print (if i=0)?

1. 6

2. Compilation error

3. 5

4. Runtime error

38. How many concrete classes can you have inside an interface?

1. 2

2. 3

3. 1

4. None

39. Which of the following statements accurately describe the use of access modifiers within a
class definition?

1. They can be applied to both data & methods

2. They must precede a class’s data variables or methods

3. They can appear in any order

4. All of the above


40. Which of the following are primitive types?

1. Byte

2. String

3. Integer

4. Float

41. What are all the methods used for Inter Thread communication and what is the class in which
these methods are defined?

1. wait()

2. notify()

3. notifyAll()

4. All the above

✅ Now this matches exactly with your images (Q15–Q41).

Do you want me to also include the answer key (the circled answers in your photos) next to each
question?

You said:

Can u make it pdf for me

ChatGPT said:

Analysis paused

You said:
Provide as it is

ChatGPT said:

I’ve created the PDF with your provided images (Questions 41–65).

📄 Download your PDF here

Do you also want me to extract the text from these images and include it in the PDF, or keep it only
as images?

You said:

No i want text

ChatGPT said:

Analysis paused

You said:

I don't want pdf text only

ChatGPT said:

Got it 👍 You just want the text version of the questions from your images (no PDF).
Here’s the extracted text from your two pages (Q.41 – Q.65):

Page 121

41.

int iBegin=1;

char iEnd=3;

System.out.println(s.substring(iBegin,iEnd));

1. Bic

2. ic

3. cy

4. error: no matched matching substring(int,char)

42. Which of the following statements about abstract methods/classes in Java are true?

1. An abstract class cannot be instantiated.

2. Constructors cannot be abstract.

3. A subclass of an abstract class must defined the abstract methods.

4. Both 1 and 2

43. What’s meant by “Passing by value” and “Passing by reference”?

1. Objects – pass by reference ; Methods – pass by value


2. Method – pass by reference ; Objects – pass by value

3. Class – pass by value ; Objects – pass by reference

4. None of the above

44. Which of the following statements correctly describes the relation between an object and the
instance variable it stores?

1. Each new object has its own distinctive set of instance variables

2. Each object has a copy of the instance variables of its class

3. The instance variable of each object are separate from the variables of other objects

4. All the above

45. The this reference is used in conjunction with ______ methods.

1. static

2. non-static

3. final

4. none of the above

46. What are the values of x and y?

x = 5; y = ++x;

1. x=6 ; y=5

2. x=6 ; y=6

3. x=5 ; y=6

4. x=6 ; y=6

47. Which keyword is used to create an instance of a class?

1. object

2. new

3. final

4. friend

48. What is the output of the following program?

public class String_args {

public static void main(String args[]) {

String s1 = "abc";

String s2 = "def";

String s3 = s1.concat(s2.toUpperCase());
System.out.println(s1+s2+s3);

1. abcdefabcdef

2. abcabcDEFDEF

3. abcdefabcDEF

4. None of the above

49. Which Java operator is right associativity?

1. *

2. /

3. =

4. =

50. Which of the following are true?

1. The Class class is the superclass of the Object class.

2. The Class class can be used to load other classes.

3. The ClassLoader class can be used to load other classes.

4. both 2 and 3

51. Which of the following not declare an array of string objects?

Page 122

52.

String [] s1;

String [] s;

String [] s1;

String s[];

53. What are the values of x and y?

x = 5; z = x++ + x;

1. x=6 ; z=6

2. x=5 ; z=6

3. x=6 ; z=5

4. x=5 ; z=5
54. Which priority Thread can prompt the lower primary Thread?

1. Lower Priority

2. Higher Priority

3. Normal Priority

4. None of the above

55. Which of the following keywords are used to control access to a class member?

1. public

2. abstract

3. protected

4. All of the above

56. Package p1 contains the following code:

package p1;

public class Student {

class result should be declared public.

1. Student class is not available.

2. Test class is not available.

3. Student class is not available.

4. Result body is not fully defined.

57. A package is a collection of

1. classes

2. classes and interfaces

3. interfaces

4. editing tools

58. The concept of multiple inheritance is implemented in Java by

1. Extending two or more classes

2. Implementing one or more interfaces

3. Implementing two or more interfaces

4. Both 2 & 3

59. What are the constants defined by both Float and Double classes?

1. MAX_RADIX
2. MIN_RADIX

3. MAX_VALUE

4. MIN_VALUE and TYPE

60. Given the following declarations

String s1 = new String("Hello");

String s2 = new String("There");

String s3 = new String();

Which of the following are legal operations?

1. s3 = s1 + s2

2. s3 = s1 - s2

3. s3 = s1 & s2

4. s3 = s1 && s2

61. Which of the following is not a wrapper class?

1. String

2. Integer

3. Boolean

4. Character

62. Garbage collector thread belongs to which priority?

1. High priority

2. Low-priority

3. Normal priority

4. None of these

63. What are the possible access modifiers when implementing interface methods?

1. Protected

2. Private

3. Public

4. None

64. Which of the following methods is used to get the error message for the exception that was
thrown?

1. print message

2. extract message
3. thrown message

4. get message

65. Java is a

1. course

2. Island

3. Subject

4. None

66. Java runs on

1. Windows

2. Unix/Linux

3. Mac

4. All of the above

You might also like